5

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.

kglr
  • 394,356
  • 18
  • 477
  • 896
Qi Zhong
  • 1,037
  • 9
  • 16
  • Method /. Charting`ResolvePlotTheme[$PlotTheme, Plot3D] -- look for the default plot style. Also search the site for ResolvePlotTheme to find many examples of its use. – Michael E2 Apr 28 '18 at 19:14
  • defaultplotstyle= "DefaultPlotStyle"/.(Method/. Charting`ResolvePlotTheme[Automatic, Plot3D]) – kglr Apr 28 '18 at 19:19

1 Answers1

6

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

kglr
  • 394,356
  • 18
  • 477
  • 896