Possible Duplicate:
Consistent Plot Styles across multiple MMA files and data sets

So, here's my problem; I have a lot of data that is shown in different plots. I want all the plots to have the same options (PlotStyle, Axes, BaseStyle, FrameTicks, etc...). I also want to be able to modify these options (because the size and FontSize change depending on where I want to use the plots, in my thesis or in a presentation) and do that without having to change each Plot function by hand.

I guess what I'm looking for is something like this:

optionPacket = PlotStyle -> {RGBColor[1, 0, 0]}, Frame -> True,
               BaseStyle -> {FontSize -> 20};

and then use it like this:

ListPlot[mydata, optionPacket]

ListPlot[mydata2, optionPacket]

Is there any way to accomplish this? (What I just posted obviously doesn't work or I wouldn't be asking).

  • $\begingroup$ You can define optionPacket = {RGBColor[1, 0, 0], Frame -> True, BaseStyle -> {FontSize -> 20}}; and then do Plot[Sin[x], {x, -1, 1}, PlotStyle -> optionPacket]. Notice your syntax is incorrect. $\endgroup$ – b.gates.you.know.what Nov 9 '12 at 12:26
  • $\begingroup$ @freda Welcome to the Mathematica StackExchange! We recommend that you register your account so you can easily keep track of answers and comments to your question. The following question (mathematica.stackexchange.com/questions/3247) possibly answers yours. $\endgroup$ – tkott Nov 9 '12 at 15:53
  • $\begingroup$ Freda, I agree with tkott — this question was asked previously and has received good answers that address your question. $\endgroup$ – rm -rf Nov 9 '12 at 16:19

Use Sequence[] for the purpose:

optionPacket = Sequence[PlotStyle -> {RGBColor[1, 0, 0]}, Frame -> True,
                        BaseStyle -> {FontSize -> 20}]

{ListPlot[RandomVariate[NormalDistribution[], {7, 2}], optionPacket],
 ListPlot[RandomVariate[WeibullDistribution[1, 2], {7, 2}], optionPacket]} // GraphicsRow

list plots

Szabolcs mentions that you can also use a plain list for the purpose, so

optionPacket = {PlotStyle -> {RGBColor[1, 0, 0]}, Frame -> True,
                BaseStyle -> {FontSize -> 20}}

works just as well.

| improve this answer | |
  • $\begingroup$ Actually you can just use a plain List of options, there's no need for Sequence. I saw this in the Visualizaion QA and I was a bit surprised it was possible. Perhaps it's worth mentioning in the answer, it's more newbie-friendly than Sequence $\endgroup$ – Szabolcs Nov 9 '12 at 15:42
  • $\begingroup$ @Szabolcs: Hmm, interesting. I remember a time when one couldn't pass a list of options (which was why the old FilterOptions[] produced a Sequence[] object as output)... $\endgroup$ – J. M.'s technical difficulties Nov 9 '12 at 15:45
  • $\begingroup$ I wouldn't expect this to work with all functions, but it does seem to work with Graphics and several (all?) plotting functions. OptionsPattern and related functions seem to handle it too. $\endgroup$ – Szabolcs Nov 9 '12 at 15:46

Another possibility is to add your settings to the options :

SetOptions[Plot, PlotStyle -> {RGBColor[1, 0, 0], Frame -> True, BaseStyle -> {FontSize -> 20}}]

Plot[Sin[x], {x, -1, 1}]



ParametricPlot[{x, Sin[x]}, {x, -1, 1}]


| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.