6
$\begingroup$

This should be a really simple question, but it isn't in the documentation for some perverse reason. I like the default ColorFunction that Mathematica uses for Plot3D and the like. I'd like to use the same color scheme for other Mathematica plots that don't have it as the automatic default. However, after looking through all of the Color Gradients listed by ColorData["Gradients"] I can't find any that match the effect of just setting ColorFunction->Automatic.

My question: What does Mathematica call its default color palette, why isn't it listed in ColorData, and how can I access it to apply it to other plots?

$\endgroup$
  • $\begingroup$ I think the default color scheme comes from PlotStyle -> White, Lighting -> Automatic, without setting any ColorFunction. $\endgroup$ – Silvia Jun 25 '13 at 17:18
12
$\begingroup$

I think the default color scheme comes from PlotStyle -> White, Lighting -> Automatic, without setting any ColorFunction.

Please compare the results of these two commands:

Row[{
    Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, ImageSize -> 200],
    Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, ImageSize -> 200,
           PlotStyle -> White,
           Lighting -> Automatic]
   }]

image comparison

Also, the documentation for Lighting states "If a color function is given to a plot, then neutral lighting is used automatically". Please compare the results of the following commands:

Row[{
    Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, ImageSize -> 200,
           ColorFunction -> (White &)],
    Show[
         Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, ImageSize -> 200,
                ColorFunction -> (White &)],
         Lighting -> Automatic]
  }]

image comparison 2

$\endgroup$
  • $\begingroup$ I think this has changed in version 10. Your first example produces slightly different results on my computer. Also do you know the default color/lighting used for version 10 for multiple plots? For example in Plot3D[{Sin[x + y^2], Cos[x + y^2]}, {x, -3, 3}, {y, -2, 2}] there are two surfaces with two different colors (yellow and blue), how can I plot only the second one Plot3D[Cos[x + y^2], {x, -3, 3}, {y, -2, 2}] with the same blue style? $\endgroup$ – xslittlegrass Sep 17 '15 at 20:13
  • $\begingroup$ @xslittlegrass Yes I think the default settings has been changed. You need to use PlotStyle -> somecolor, Lighting -> "Neutral" to mimic the default style. But I'm not sure which exact color it is.. $\endgroup$ – Silvia Sep 19 '15 at 16:28
  • $\begingroup$ @xslittlegrass I think you can get the colors by this way: Plot3D[Evaluate@Range[10],{x,0,1},{y,0,1},PlotPoints->2,MaxRecursion->0]//Cases[#,Directive[___,c_RGBColor,___]:>c,∞]&. $\endgroup$ – Silvia Sep 19 '15 at 16:37
  • $\begingroup$ @xslittlegrass And the Lighting is not "Neutral", it's ............ Lighting->{{"Ambient",RGBColor[0.30100577,0.22414668499999998`,0.090484535]},{"Directional",RGBColor[0.2642166,0.18331229999999998`,0.04261530000000001],ImageScaled[{0,2,2}]},{"Directional",RGBColor[0.2642166,0.18331229999999998`,0.04261530000000001],ImageScaled[{2,2,2}]},{"Directional",RGBColor[0.2642166,0.18331229999999998`,0.04261530000000001],ImageScaled[{2,0,2}]}}. $\endgroup$ – Silvia Sep 19 '15 at 16:43
  • $\begingroup$ Thanks. But I'm still not able to make it work. See here. By the way how can you get the default lighting information? $\endgroup$ – xslittlegrass Sep 19 '15 at 19:41
11
$\begingroup$

The howto/ChangeTheLightingOfPlots section of the documentation centre specifies the default lighting settings:

Graphics3D[Sphere[], 
 Lighting -> {{"Ambient", 
    RGBColor[{0.312, 0.188, 0.4}]}, {"Directional", 
    RGBColor[{0.8, 0., 0.}], ImageScaled[{2, 0, 2}]}, {"Directional", 
    RGBColor[{0., 0.8, 0.}], ImageScaled[{2, 2, 2}]}, {"Directional", 
    RGBColor[{0., 0., 0.8}], ImageScaled[{0, 2, 2}]}}]

So, the object coloring derives from using colored lights, not from a coloring function.

$\endgroup$
  • $\begingroup$ Aha I know I saw it somewhere! (+1) $\endgroup$ – Silvia Jun 25 '13 at 21:55
  • 1
    $\begingroup$ Is there a way to have the same color in all view angles? I tried "Lighting->None" but it didn't work! $\endgroup$ – H. R. Jan 24 '17 at 14:07
0
$\begingroup$

Using Trace I extracted the default PlotStyle for many of the 3D plots:

Directive[Specularity[GrayLevel[1], 3], RGBColor[0.880722, 0.611041, 0.142051],   Lighting -> {{"Ambient", RGBColor[      0.30100577, 0.22414668499999998`, 0.090484535]}, {"Directional",      RGBColor[0.2642166, 0.18331229999999998`, 0.04261530000000001],      ImageScaled[{0, 2, 2}]}, {"Directional", RGBColor[      0.2642166, 0.18331229999999998`, 0.04261530000000001],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.2642166, 0.18331229999999998`, 0.04261530000000001],      ImageScaled[{2, 0, 2}]}}, AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 3], RGBColor[   0.368417, 0.506779, 0.709798],   Lighting -> {{"Ambient", RGBColor[      0.19699838300000003`, 0.252204821,       0.33320940200000004`]}, {"Directional", RGBColor[      0.15473514000000002`, 0.21284718000000002`,       0.29811516000000005`], ImageScaled[{0, 2, 2}]}, {"Directional",      RGBColor[      0.15473514000000002`, 0.21284718000000002`,       0.29811516000000005`], ImageScaled[{2, 2, 2}]}, {"Directional",      RGBColor[      0.15473514000000002`, 0.21284718000000002`,       0.29811516000000005`], ImageScaled[{2, 0, 2}]}},   AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 3], RGBColor[   0.560181, 0.691569, 0.194885],   Lighting -> {{"Ambient", RGBColor[      0.1830429875, 0.21424763749999998`,       0.0962851875]}, {"Directional", RGBColor[      0.14004525, 0.17289224999999997`, 0.048721249999999994`],      ImageScaled[{0, 2, 2}]}, {"Directional", RGBColor[      0.14004525, 0.17289224999999997`, 0.048721249999999994`],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.14004525, 0.17289224999999997`, 0.048721249999999994`],      ImageScaled[{2, 0, 2}]}}, AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 6], RGBColor[   0.922526, 0.385626, 0.209179],   Lighting -> {{"Ambient", RGBColor[      0.30756835, 0.18676585, 0.147065275]}, {"Directional", RGBColor[      0.2306315, 0.0964065, 0.05229475],      ImageScaled[{0, 2, 2}]}, {"Directional", GrayLevel[0.3],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.2306315, 0.0964065, 0.05229475], ImageScaled[{2, 0, 2}]}},   AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 6], RGBColor[   0.528488, 0.470624, 0.701351],   Lighting -> {{"Ambient", RGBColor[      0.41139519999999996`, 0.3882496, 0.4805404]}, {"Directional",      RGBColor[0.264244, 0.235312, 0.3506755],      ImageScaled[{0, 2, 2}]}, {"Directional", Hue[0.7, 1, 1],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.264244, 0.235312, 0.3506755], ImageScaled[{2, 0, 2}]}},   AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 6], RGBColor[   0.772079, 0.431554, 0.102387],       Lighting -> {{"Ambient", RGBColor[      0.35441579999999995`, 0.2863108, 0.2204774]}, {"Directional",      RGBColor[0.19301974999999993`, 0.1078885, 0.02559675],      ImageScaled[{0, 2, 2}]}, {"Directional", GrayLevel[0.3],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.19301974999999993`, 0.1078885, 0.02559675],      ImageScaled[{2, 0, 2}]}}, AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 6], RGBColor[   0.363898, 0.618501, 0.782349],   Lighting -> {{"Ambient", RGBColor[      0.28733552, 0.34844024, 0.38776376]}, {"Directional", RGBColor[      0.10916940000000003`, 0.1855503, 0.2347047],      ImageScaled[{0, 2, 2}]}, {"Directional", RGBColor[      0.10916940000000003`, 0.1855503, 0.2347047],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.10916940000000003`, 0.1855503, 0.2347047],      ImageScaled[{2, 0, 2}]}}, AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 3], RGBColor[1, 0.75, 0],   Lighting -> {{"Ambient", RGBColor[      0.334, 0.2755000000000001, 0.1]}, {"Directional", RGBColor[      0.26, 0.19500000000000006`, 0.],      ImageScaled[{0, 2, 2}]}, {"Directional", GrayLevel[0.1],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.26, 0.19500000000000006`, 0.], ImageScaled[{2, 0, 2}]}},   AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 6], RGBColor[   0.647624, 0.37816, 0.614037],   Lighting -> {{"Ambient", RGBColor[      0.40723968, 0.3210112, 0.39649184000000004`]}, {"Directional",      RGBColor[0.2590496, 0.151264, 0.24561480000000002`],      ImageScaled[{0, 2, 2}]}, {"Directional", GrayLevel[0.3],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.2590496, 0.151264, 0.24561480000000002`],      ImageScaled[{2, 0, 2}]}}, AbsoluteThickness[2]],  
Directive[Specularity[GrayLevel[1], 6], RGBColor[   0.571589, 0.586483, 0.],   Lighting -> {{"Ambient", RGBColor[      0.36004492, 0.36421523999999994`, 0.2]}, {"Directional",      RGBColor[0.20005615, 0.20526904999999995`, 0.],      ImageScaled[{0, 2, 2}]}, {"Directional", RGBColor[      0.20005615, 0.20526904999999995`, 0.],      ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[      0.20005615, 0.20526904999999995`, 0.], ImageScaled[{2, 0, 2}]}},   AbsoluteThickness[2]]

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.