5
$\begingroup$

I would like to know the default PlotStyle for Plot3D. Below are two codes, one is the default setting and another is my setting.

Default:

Plot3D[{z=1/2(x^2+y^2), z=x^2+y^2, z=2(x^2+y^2), z=3(x^2+y^2)},
{x,-1,1}, {y,-1,1}, Mesh->None]

enter image description here

My:

Plot3D[{z=1/2(x^2 + y^2), z=x^2+y^2, z=2(x^2+y^2), z=3(x^2+y^2)}, 
{x,-1,1}, {y,-1,1}, Mesh->None, 
PlotStyle -> {ColorData[97, "ColorList"][[2]], ColorData[97, "ColorList"][[1]], 
ColorData[97, "ColorList"][[3]], ColorData[97, "ColorList"][[4]]}]

enter image description here

I know there should be some other settings in the default style, such as Specularity. I want to use the default style except that use different colors or change the order of default colors.

$\endgroup$
2
  • $\begingroup$ Method /. Charting`ResolvePlotTheme[$PlotTheme, Plot3D] -- look for the default plot style. Also search the site for ResolvePlotTheme to find many examples of its use. $\endgroup$
    – Michael E2
    Apr 28, 2018 at 19:14
  • $\begingroup$ defaultplotstyle= "DefaultPlotStyle"/.(Method/. Charting`ResolvePlotTheme[Automatic, Plot3D]) $\endgroup$
    – kglr
    Apr 28, 2018 at 19:19

1 Answer 1

6
$\begingroup$

Default PlotStyle

defaultplotstyle = "DefaultPlotStyle" /. 
   (Method /. Charting`ResolvePlotTheme[Automatic, Plot3D])

enter image description here

p1 = Plot3D[{1/2 (x^2 + y^2), x^2 + y^2, 2 (x^2 + y^2), 3 (x^2 + y^2)},
   {x, -1, 1}, {y, -1, 1}, Mesh -> None, ImageSize -> 300];
 p2 = Plot3D[{1/2 (x^2 + y^2), x^2 + y^2, 2 (x^2 + y^2), 3 (x^2 + y^2)},
   {x, -1, 1}, {y, -1, 1}, Mesh -> None, ImageSize -> 300, PlotStyle -> defaultplotstyle];
Row[{p1, p2}]

enter image description here

and how to replace the colors

I want to use the default style except that use different colors or change the order of default colors

To use a different set of colors, say, RandomSample[ColorData[43, "ColorList"]] with the same Lighting and Specularity settings as the default style, you can modify defaultplotstyle as follows:

newcolors = RandomSample[ColorData[43, "ColorList"]][[;;4]];
newplotstyle = defaultplotstyle[[;;4]];
newplotstyle[[All, 2]] = newcolors;

Using PlotStyle -> newplotstyle gives

enter image description here

To change the order of colors, use, say, PlotStyle -> defaultplotstyle[[{2, 1, 4, 3}]] to get

enter image description here

See also: search results for ResolvePlotTheme on this site

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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