Skip to main content

plotting - What are the standard colors for plots in Mathematica 10?




Mathematica 10 release appears to have changed the default styling of plots: the most visible changes are thicker lines and different default colors.


Thus, answers to this stackoverflow question are only valid for Mathematica < 10. For example, plots in this code will not give identical output in Mathematica 10, although they do in version 9:


fns = Table[x^n, {n, 0, 5}];
Plot[fns, {x, -1, 1}, PlotStyle -> ColorData[1, "ColorList"]]
Plot[fns, {x, -1, 1}]

enter image description here


So, my question is: what is the new way of getting the default colors to reproduce for own uses?



Answer




The colors alone are indexed color scheme #97:


ColorData[97, "ColorList"]

enter image description here


Update: further digging in reveals these PlotTheme indexed color relationships:


{"Default"   -> 97,  "Earth"       -> 98,  "Garnet"      -> 99,  "Opal"       -> 100,
"Sapphire" -> 101, "Steel" -> 102, "Sunrise" -> 103, "Textbook" -> 104,
"Water" -> 105, "BoldColor" -> 106, "CoolColor" -> 107, "DarkColor" -> 108,
"MarketingColor" -> 109, "NeonColor" -> 109, "PastelColor" -> 110, "RoyalColor" -> 111,
"VibrantColor" -> 112, "WarmColor" -> 113};


The colors are returned as plain RGBColor expressions; the colored squares are merely a formatting directive. You can still see the numeric data with:


ColorData[97, "ColorList"] // InputForm


{RGBColor[0.368417, 0.506779, 0.709798], . . .,
RGBColor[0.28026441037696703, 0.715, 0.4292089322474965]}

You can get a somewhat nicer (rounded decimal) display using standard output by blocking the formatting rules for RGBColor using Defer:


Defer[RGBColor] @@@ ColorData[97, "ColorList"] // Column



RGBColor[0.368417, 0.506779, 0.709798]
. . .
RGBColor[0.280264, 0.715, 0.429209]

To get full styling information for the default and other Themes see:



For example:


Charting`ResolvePlotTheme[Automatic, Plot]


enter image description here


(Actually Automatic doesn't seem to be significant here as I get the same thing using 1 or Pi or "" in its place; apparently anything but another defined Theme.)


Comments

Popular posts from this blog

mathematical optimization - Minimizing using indices, error: Part::pkspec1: The expression cannot be used as a part specification

I want to use Minimize where the variables to minimize are indices pointing into an array. Here a MWE that hopefully shows what my problem is. vars = u@# & /@ Range[3]; cons = Flatten@ { Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; Minimize[{Total@((vec1[[#]] - vec2[[u[#]]])^2 & /@ Range[1, 3]), cons}, vars, Integers] The error I get: Part::pkspec1: The expression u[1] cannot be used as a part specification. >> Answer Ok, it seems that one can get around Mathematica trying to evaluate vec2[[u[1]]] too early by using the function Indexed[vec2,u[1]] . The working MWE would then look like the following: vars = u@# & /@ Range[3]; cons = Flatten@{ Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; NMinimize[ {Total@((vec1[[#]] - Indexed[vec2, u[#]])^2 & /@ R...

functions - Get leading series expansion term?

Given a function f[x] , I would like to have a function leadingSeries that returns just the leading term in the series around x=0 . For example: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x)] x and leadingSeries[(1/x + 2 + (1 - 1/x^3)/4)/(4 + x)] -(1/(16 x^3)) Is there such a function in Mathematica? Or maybe one can implement it efficiently? EDIT I finally went with the following implementation, based on Carl Woll 's answer: lds[ex_,x_]:=( (ex/.x->(x+O[x]^2))/.SeriesData[U_,Z_,L_List,Mi_,Ma_,De_]:>SeriesData[U,Z,{L[[1]]},Mi,Mi+1,De]//Quiet//Normal) The advantage is, that this one also properly works with functions whose leading term is a constant: lds[Exp[x],x] 1 Answer Update 1 Updated to eliminate SeriesData and to not return additional terms Perhaps you could use: leadingSeries[expr_, x_] := Normal[expr /. x->(x+O[x]^2) /. a_List :> Take[a, 1]] Then for your examples: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x), x] leadingSeries[Exp[x], x] leadingSeries[(1/x + 2 + (1 - 1/x...

What is and isn't a valid variable specification for Manipulate?

I have an expression whose terms have arguments (representing subscripts), like this: myExpr = A[0] + V[1,T] I would like to put it inside a Manipulate to see its value as I move around the parameters. (The goal is eventually to plot it wrt one of the variables inside.) However, Mathematica complains when I set V[1,T] as a manipulated variable: Manipulate[Evaluate[myExpr], {A[0], 0, 1}, {V[1, T], 0, 1}] (*Manipulate::vsform: Manipulate argument {V[1,T],0,1} does not have the correct form for a variable specification. >> *) As a workaround, if I get rid of the symbol T inside the argument, it works fine: Manipulate[ Evaluate[myExpr /. T -> 15], {A[0], 0, 1}, {V[1, 15], 0, 1}] Why this behavior? Can anyone point me to the documentation that says what counts as a valid variable? And is there a way to get Manpiulate to accept an expression with a symbolic argument as a variable? Investigations I've done so far: I tried using variableQ from this answer , but it says V[1...