Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: "Sticky" options when using Plot[] -- bug or feature?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99468] Re: [mg99403] "Sticky" options when using Plot[] -- bug or feature?
  • From: Curtis Osterhoudt <cfo at lanl.gov>
  • Date: Wed, 6 May 2009 05:25:14 -0400 (EDT)
  • Organization: LANL
  • References: <200905050940.FAA20671@smc.vnet.net>
  • Reply-to: cfo at lanl.gov

   If you don't want to use things like Block (which should localize the options you pass to Plot), then you can save the system options to a variable (before the SetOptions command you use), then restore them after the plot is produced. Something like: 

<< PlotLegends`
bs = {FontFamily -> "Arial", FontSize -> 14, FontWeight -> Bold};
defaultPlotOptions = Options@Plot;

and then, where you want, use 

SetOptions[Plot, defaultPlotOptions];

You should then regain the "normal" looking plots.

               Cheers, 
                         C.O.



On Tuesday 05 May 2009 03:40:07 am Bob F wrote:
> Any idea why the first and last "Plot[Cos[x], {x, -Pi, Pi}]" below
> come out so much differently? It would appear that some of the options
> are a bit "sticky" in the sense that they are not reset for the second
> "Plot[Cos[x], {x, -Pi, Pi}]". Is this a bug or a feature? And make
> sure that you start with a fresh kernel in case something has already
> been done for the first Plot[] call ...
> 
> Plot[Cos[x], {x, -Pi, Pi}]
> 
> << PlotLegends`
> bs = {FontFamily -> "Arial", FontSize -> 14, FontWeight -> Bold};
> SetOptions[Plot, Frame -> True, FrameStyle -> AbsoluteThickness[2],
>   GridLines -> Automatic,
>   PlotStyle -> {{Red, AbsoluteThickness[2]}, {Black,
>      AbsoluteThickness[2]}, {Blue,
>      AbsoluteThickness[2]}, {Darker@Green, AbsoluteThickness[2]}},
>   BaseStyle -> bs];
> Plot[{Sin[x], Cos[x], Tan[x]}, {x, 0, 1},
>  PlotStyle -> {Directive[Blue, Thick],
>    Directive[Thick, Red, DotDashed], Directive[Thick, Green, Dotted]},
>   Background -> LightOrange,
>  PlotLegend -> {"sin x", "cos x", "tan x"},
>  LegendPosition -> {-.6, 0.1}, LegendOrientation -> Vertical,
>  LegendBackground -> LightPurple, LegendShadow -> {.02, -.02},
>  LegendSize -> {0.3, 0.35}, FrameLabel -> {"x", "trig functions"}]
> 
> Plot[Cos[x], {x, -Pi, Pi}]
> 
> Please let me know if you find the same problem. I tried this on a Mac
> OS X 10.5.6 system with version 7.0.1 of Mathematica. Thanks...
> 
> -Bob
> 
> 


-- 
==================================
Curtis Osterhoudt
cfo at remove_this.lanl.and_this.gov
PGP Key ID: 0x4DCA2A10
==================================



  • Prev by Date: Re: Some function like Position[] but uses criteria, not pattern?
  • Next by Date: Re: "Sticky" options when using Plot[] -- bug or feature?
  • Previous by thread: "Sticky" options when using Plot[] -- bug or feature?
  • Next by thread: Re: "Sticky" options when using Plot[] -- bug or feature?