3

I like quiet and undisturbed color gamut and lighting of 3D plots in Mathematica 5.

Is it possible to style 3D plots in Mathematica 7 exactly as it was in Mathematica 5?

Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, ImageSize -> 360]
<< Version5`Graphics`
Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, ImageSize -> 360]

Screenshot of the Output


This code allows to compare easily visual appearance of version 5 and version 7 graphics:

v5style = {{"Ambient", RGBColor[{0.356, 0.294, 0.4}]}, {"Directional",
     RGBColor[{0.56, 0., 0.}], 
    ImageScaled[{2, 0, 2}]}, {"Directional", RGBColor[{0., 0.56, 0.}],
     ImageScaled[{2, 2, 2}]}, {"Directional", 
    RGBColor[{0., 0., 0.56}], ImageScaled[{0, 2, 2}]}};

PostScriptGraphics /: MakeBoxes[PostScriptGraphics[str_String], _] := 
 Cell[GraphicsData["PostScript", str], CellAutoOverwrite -> True, 
  CellBaseline -> Center]
v5vsv7[\[Theta]_] := {Developer`LegacyGraphics[];
   v5Graphics = 
    Graphics`Legacy`Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, 
     ImageSize -> 360, 
     ViewPoint -> RotationTransform[\[Theta], {0, 0, 1}][{3, 0, 3}]];
   v5PostScript = ExportString[v5Graphics, "APS"];
   Developer`SymbolicGraphics[];
   PostScriptGraphics[v5PostScript],
   Graphics3D[First@Graphics3D@v5Graphics, 
     FilterRules[Last@Graphics3D@v5Graphics, Options[Graphics3D]], 
     ViewPoint -> RotationTransform[\[Theta], {0, 0, 1}][{3, 0, 3}], 
     PlotRangePadding -> None, 
     ImageSize -> 360] /. (Lighting -> _) -> (Lighting -> v5style)};

Grid@Table[v5vsv7[\[Theta]], {\[Theta], 0, 2 Pi, Pi}]
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93
  • @Mr.Wizard **Close** in meaning that I wish to have vertex coloring working. But in general **as close as it is possible**. – Alexey Popkov Apr 28 '11 at 06:09
  • Okay. I shall think about this. Another good question Alexey. I have not used v5 in a long time, I will have to try to remember how it worked. – Mr.Wizard Apr 28 '11 at 07:34
  • Thanks. I'll take your comments about `Lighting` and `ColorFunction` into account as soon as I can get back to them. (Commenting is turned off in my response area, for some reason; that's why I answered you here.) – DavidC Apr 28 '11 at 13:06

2 Answers2

4

Mr. W already answered your question well, I think. Here's a toy to play around with some possibilities, including other palettes. It starts with the values Mr. W used.

Manipulate[
  Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, PlotLabel -> cf, 
  ImageSize -> 360, ColorFunction -> cf, Mesh -> mesh,
  Lighting -> {{"Ambient", cs},
    {"Directional", RGBColor[{s, 0., 0.}], 
     ImageScaled[{2, 0, 2}]}, {"Directional", RGBColor[{0., s, 0.}], 
     ImageScaled[{2, 2, 2}]}, {"Directional", RGBColor[{0., 0., s}], 
     ImageScaled[{0, 2, 2}]}}],
{{cf, None, "color function"}, Prepend[ColorData["Gradients"], None]},
{{cs, RGBColor[{0.356, 0.294, 0.4}]}, ColorSlider},
{{s, .5, "brightness"}, 0, 1, Appearance -> "Labeled"},
{{mesh, 15}, 0, 30, 1, Appearance -> "Labeled"}]

manipulatte

DavidC
  • 3,056
  • 1
  • 20
  • 30
  • +1 nice display. My English is not enough to catch the meaning of "undisturbed" here. Could you explain, please? – Dr. belisarius Apr 28 '11 at 11:36
  • @belisarius I just updated it with Manipulate. Decrease the brightness to get a less disturbed (i.e. "darker") rendering. Cheers – DavidC Apr 28 '11 at 11:48
  • ["In three‐dimensional graphics, ColorFunction is used only with the option setting `Lighting` -> False."](http://reference.wolfram.com/legacy/v5/Built-inFunctions/GraphicsAndSound/AdvancedOptions/ColorFunction.html) while [by default for `Plot3D` `Lighting`->True](http://reference.wolfram.com/legacy/v5/Built-inFunctions/GraphicsAndSound/3DPlots/FurtherExamples/Plot3D.html). So the problem can not be solved just by specifying different `ColorFunction`. – Alexey Popkov Apr 28 '11 at 11:48
  • @belisarius "Undisturbed" is just a synonym of "quiet" in this context with nuances of "peaceful" and "unworried". – Alexey Popkov Apr 28 '11 at 11:56
  • @David Commenting is enabled, as I see. Probably the problem is with your web browser. Try to do hard reloading of the page (in FireFox it can be done by pressing Ctrl+F5, Opera has another combination and corresponding item in menus). – Alexey Popkov Apr 28 '11 at 13:14
  • @Alexey A hard reloading didn't work for me. But when I opened the page a couple hours later, everything was back to normal. SO demons? – DavidC Apr 28 '11 at 14:38
  • @belisarius Re: "disturbed". This is a completely subjective, almost poetic matter. Some would claim that "dark" and "disturbed" are neighbors. I took it to mean "subdued, not flamboyant". That's slightly different from Alexy's take. (But it's his take that really matters here.) – DavidC Apr 28 '11 at 15:25
  • @David From time to time I have similar problems here and hard reloading with cache cleanup always help. I think that this happens when JavaScripts used in pages of this site are updated on site but not or not fully updated in the browser's cache. – Alexey Popkov Apr 28 '11 at 16:40
  • @Alexey Does clicking on the arrow in the right corner of the address bar do a "hard" reload? – DavidC Apr 28 '11 at 17:10
  • 1
    @David No. It just load the same page if it is changed from the last load. The problem with this site is more subtle: its interface is based on JavaScript files which are not a part of the page itself but are loaded (if the browser considers them changed) on request from the entire code of the loaded page. Without these files all interactive functionality of this site does not work. These files may be for some reason corrupted in the browser's cache or changed on the server and incompatible (if they are not updated in the browser's cache). The solution is to clear the cache and reload page. – Alexey Popkov Apr 28 '11 at 17:50
  • 1
    @David Hard reload (Ctrl+F5 in FireFox) forces browser to load the page (but not other needed files) even this page "is not changed on the server" (as browser "think"). Cache cleanup forces browser to load all contents needed to display the page, not just the page itself. So the universal solution always is to clean the cache and then reload the page (not required hard reload in this case). The only problem is with Microsoft Internet Explorer: it does not invariable clears all its cache content if you press the corresponding button. It is well-known bug of all versions of Internet Explorer. – Alexey Popkov Apr 28 '11 at 18:03
  • @David If you use Internet Explorer you may be interested in [this](http://www.enigmaticsoftware.com/cachesentry/index.html#overview) little free program that fixes the mention bug of Internet Explorer. – Alexey Popkov Apr 28 '11 at 18:10
  • @Thanks, but I only use Firefox and Safari. – DavidC Apr 28 '11 at 18:22
  • @David So just clear the cache and *then* reload the page if you encounter problems with this site! – Alexey Popkov Apr 28 '11 at 18:29
1

Is this approaching close enough, or still a long way off of your requirements?

new = {{"Ambient", RGBColor[{0.356, 0.294, 0.4}]}, {"Directional", 
  RGBColor[{0.56, 0., 0.}], ImageScaled[{2, 0, 2}]}, {"Directional", 
  RGBColor[{0., 0.56, 0.}], ImageScaled[{2, 2, 2}]}, {"Directional", 
  RGBColor[{0., 0., 0.56}], ImageScaled[{0, 2, 2}]}};

Plot3D[Sin[x y], {x, 0, Pi}, {y, 0, Pi}, Lighting -> new, Mesh -> 20]

enter image description here

Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125
  • 1
    I just puzzled a bit by choice of colors for `Lighting` option. On the [documentation page for version 5](http://reference.wolfram.com/legacy/v5/Built-inFunctions/GraphicsAndSound/GraphicsPrimitives/Graphics3D.html) all the colors are simple: – Alexey Popkov Apr 28 '11 at 11:27
  • for the v.5 [`LightSources`](http://reference.wolfram.com/legacy/v5/Built-inFunctions/GraphicsAndSound/3DOptions/LightSources.html) option the defaults are `{{{1,0,1}, RGBColor[1,0,0]}, {{1,1,1}, RGBColor[0,1,0]}, {{0,1,1}, RGBColor[0,0,1]}}`, for the [`AmbientLight`](http://reference.wolfram.com/legacy/v5/Built-inFunctions/GraphicsAndSound/3DOptions/AmbientLight.html) option the default is `GrayLevel[0]`. And `LightSources` are described as *point light sources*. – Alexey Popkov Apr 28 '11 at 11:27
  • 1
    But of course simple substituting of those settings into `Lighting` does not give the desired lighting. – Alexey Popkov Apr 28 '11 at 11:35
  • 1
    Setting `Mesh->23` or `PlotPoints->25, Mesh->Full` produces the same mesh as in version 5. – Alexey Popkov Apr 28 '11 at 12:07
  • @Alexey, the "point" sources should be similar to "Directional" but I scaled the numbers so they were less bright. The ambient light was based on what I found for the default, but adjusted a little for a better match. – Mr.Wizard Apr 28 '11 at 20:17
  • @Mr.Wizard Finally after thinking about this new visual appearance I feel myself not satisfied. This style looses some special appeal of the version 5 style, probably connected with the yellow illumination at the center. I think it is substantial loss since the plot looks toneless. Could you please try to fix this? – Alexey Popkov Apr 29 '11 at 02:48
  • @Alexey, I see what you mean. I'll try again. – Mr.Wizard Apr 29 '11 at 06:00
  • @Mr.Wizard See also edited part of my question. May be useful. – Alexey Popkov Apr 29 '11 at 06:43
  • @Alexey, looking at those rotations (and more in finer steps), I don't know if it is possible to really approximate the old style. There are differences in the lighting method that I don't know how to compensate for. – Mr.Wizard Apr 29 '11 at 07:35
  • @Mr.Wizard What do you think, what exactly are the differences in the lighting algorithms? – Alexey Popkov Apr 29 '11 at 07:52
  • @Alexey, I don't know nearly enough to try to answer that. [There are different shading methods](http://en.wikipedia.org/wiki/List_of_common_shading_algorithms) that could be used, as well as simulated material properties such as specularity. Also, "Point" and "Directional" are not the same as I indicated earlier. That is worthy of exploration. – Mr.Wizard Apr 29 '11 at 08:27
  • @Mr.Wizard Is it impossible to achieve similar result with "Point" instead of "Directional"? I tried to use it but the resulting plot is too dark. Is it possible to make it lighter? – Alexey Popkov Apr 29 '11 at 09:18
  • 1
    @Alexey I tried "Point" too, and the light directions seem wrong (rather than intensity). Perhaps with the right rotation of the coordinates it will be close, but I don't have time to try right now. – Mr.Wizard Apr 29 '11 at 09:35
  • @Mr.Wizard I just have noticed that with "Point" the colors of the plot does not change when rotating it. It means that the "Point" light sources are fixed in the coordinate system and rotate with the plot. – Alexey Popkov Apr 29 '11 at 10:40
  • @Mr.Wizard As I understand you have got in some a way the default value of `Automatic` option for `Lighting`. How did you manage that? – Alexey Popkov Apr 30 '11 at 01:50
  • @Alexey, [from this MathGroup thread](http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/c4b520f44fb2a2b7/). I didn't link to it before because I didn't think it would help further. – Mr.Wizard Apr 30 '11 at 01:58