Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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).

share|improve this question

marked as duplicate by The Toad Nov 9 '12 at 16:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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. –  b.gatessucks Nov 9 '12 at 12:26
@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 ( possibly answers yours. –  tkott Nov 9 '12 at 15:53
Freda, I agree with tkott — this question was asked previously and has received good answers that address your question. –  The Toad Nov 9 '12 at 16:19

2 Answers 2

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.

share|improve this answer
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 –  Szabolcs Nov 9 '12 at 15:42
@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)... –  Guess who it is. Nov 9 '12 at 15:45
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. –  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}]


share|improve this answer

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