All of my plots should have the same set styling, that is, for instance, {ImageSize->460, Frame->True, PlotStyle->Thickness[0.004]}.

Of course I do not want to repeat these settings in every Plot.

SetOptions[] is a convenient way to set the standards for ImageSize and Frame. However, it fails for defining the thickness. Often I need to use extra plot styling options such as dashing of colour. In these cases the setting for the plot thickness is overwritten.

Is there an easy way to define the standard plot thickness such that is is not reset when I use a command Plot[x,{x,0,4}, PlotStyle->Red]?

The only way I found is to write a custom plot which intercepts the OptionsPattern[], checks if PlotStyle and Thickness is defined and, if Thickness is not defined adds it to the PlotStyle list and runs Plot[].

However, this is long process. And needs to account for single and multiple plots. Below is an example for a single plot, that is, Plot[x,{x,0,4}, PlotStyle->Red] works Plot[{x,x^2},{x,0,4}, PlotStyle->{Red,Green}] does not.

    AddItems[oldItems_, newItems_] := Module[{ii},
  out = oldItems;
  For[ii = 1, ii <= Length[newItems], ii++,
    out = 
     out /. Rule[newItems[[ii, 1]], _] :> 
       Rule[newItems[[ii, 1]], newItems[[ii, 2]]];
  out = DeleteDuplicates[Join[out, newItems]]
MyPlot[a_, b_, opts : OptionsPattern[]] := Module[{plotStyle, optsOut},
  plotStyle = PlotStyle /. {opts};
  If[plotStyle === PlotStyle,
    optsOut = AddItems[{opts}, {PlotStyle -> Thickness[0.004]}]
    plotStyle = Join[{Thickness[0.004]}, Flatten[{plotStyle}]];
    optsOut = AddItems[{opts}, {PlotStyle -> plotStyle}];
  Plot[a, b, Evaluate[optsOut]]

EDIT: Thanks kuba, using BaseStyle -> Thickness[0.004] solves it. Was looking for that for so long.


Browse other questions tagged or ask your own question.