2
$\begingroup$

This question (at least for v10) seems to have been asked many times, but I cannot decipher the answers. I have read a few posts about this - but I don't know how to use any of the answers (e.g. How to access new colour schemes in version 10?,What are the standard colors for plots in Mathematica 10? [duplicate], What's the default colormap (or color scheme) used in mathematica?).

Can anyone provide some basic example code that would let you plot using say the third default colour?

e.g. if I wanted to replicate only the cubic curve in the first plot, but keep the same colouring for this line between my two plots how would I fix my code?

Plot[{x,x^2,x^3},{x,0,5}]

Plot[{x^3},{x,0,5},PlotStyle->DefaultLineColour3]

what do you replace DefaultLineColour3 with?

I'm hoping there's a way to access the Default Colours rather than get the rgb commands, and then define my own colour commands at the start of the notebook to cycle through this list, and then use this - but I'm not sure this is possible. Probably obvious - but it's not specifically the 3rd line colour I'm interested in that is just an example (so giving me the RGB code for that colour isn't what I am looking for).

Please don't just mark this as a duplicate - I know the question has been asked before it's just that the answers aren't at all helpful for a basic user.

$\endgroup$
5
$\begingroup$

Simply stated,

The default color scheme for Plot as of Mathematica 10, 11 and 12 is ColorData[97]

To get the third default color, you may use ColorData[97, 3].

Example:

Plot[x^2, {x, 0, 5}, PlotStyle -> ColorData[97, 3]]

Mathematica graphics

$\endgroup$
3
$\begingroup$

To verify that ColorData[97] is the default color function for Plot you can use

"DefaultColor" /. Themes`DefaultStyles[Plot][[All, 2]]

97

To get the default styles for Plot you can use:

"DefaultPlotStyle" /. (Method /. Charting`ResolvePlotTheme[Automatic, Plot])

enter image description here

Pick the first parts to get the colors,

("DefaultPlotStyle" /. (Method /. 
        Charting`ResolvePlotTheme[Automatic, Plot]))[[All, 1]]

enter image description here

and the third element of the resulting list:

defaultLineColour3 = ("DefaultPlotStyle" /. (Method /. 
    Charting`ResolvePlotTheme[Automatic, Plot]))[[All, 1]][[3]];

Plot[{x^3}, {x, 0, 5}, PlotStyle -> defaultLineColour3]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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