Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have one more problem, still with exporting full quality 3d figure into Word. I want perfect quality in a Word document of a 3d figure prepared with legend (traditional form of text). Extremes of the function in figure is nice to be yellow and rest of the function feature red.


  Plot3D[Sin[4 x]*Cos[4 y], {x, -2, 2}, {y, -2, 2}]

I need this figure to import in Word with full prepared legend and combination of color (red-yellow).

share|improve this question
I can't figure out what exactly the question is. What is the link supposed to tell us? –  Jens Jan 15 '13 at 19:19
This appears to cover exactly the same ground as your previous question at mathematica.stackexchange.com/questions/17706/… –  whuber Jan 15 '13 at 19:54
@Jens I think he wants the graphics like this question. Or he wants to employ you as private consultant... :) –  cormullion Jan 15 '13 at 19:56
@Jens question is how to prepare figure for word in best quality. link is just about coloring (red-yellow combination of the 3d function), I need in extreme region yellow and other part of the graphic red. –  Pipe Jan 15 '13 at 20:01
Sorry, I don't have word so I don't feel qualified to answer this, because I cannot define "best quality". –  Jens Jan 15 '13 at 20:33
show 5 more comments

1 Answer

up vote 4 down vote accepted

Here is what I can say: to make a 3d plot with the color scheme you want and then give it a label, you can in fact rely on another answer I posted to the question "ShowLegend values". The steps are as follows:

  1. From the linked answer, copy the second code block (below the heading Color bar legend) defining the functions trimPoint, all the way down to display, and execute them in your notebook. These definitions are used to arrange information about a plot as a legend.

  2. Now we'll make your example plot with some nice colors.

Here I've chosen the SunsetColors scheme from the Palettes > Color Schemes menu. You could make your own scheme using Blend.

plot = Plot3D[Sin[4 x]*Cos[4 y], {x, -2, 2}, {y, -2, 2}, 
  ColorFunction -> "SolarColors"]


  1. Next, make the labeled plot.

The information we need for the label is the range of z values to which the colors correspond, and the color function. The other numbers are relative dimensions of the plot versus label:

  range = {-1, 1},
  plotWidth = .8,
  labelHeight = .5,
  labelWidth = .15
   plot // at[{0, 0}, plotWidth], 
   colorLegend[ColorData["SolarColors"], range, Contours -> 8] // 
    at[{0.85, .1}, Scaled[{labelWidth, labelHeight}]]}, 
  AspectRatio -> .75]


The commands display and at are explained in the answer linked above. The rest is to export this plot as a suitable image (I guess). That would be


An alternative to using my display function for the legend is to hand-craft your own legend using the general approaches in the answers to "Spreading colors in ListDensityPlot". The reason I wrote my solution was so the legending process can be automated more. In my earlier answer, I had also defined a function reportColorRange that can automatically keep track of the range of colors and function values, but it only works for 2D plots because the ColorFunction option in 3D takes additional arguments that I didn't make any provisions for.

share|improve this answer
Thank you very much. This is what I wanted to obtain. Very kind regards –  Pipe Jan 15 '13 at 22:46
code started with "with" doesn't work? –  Pipe Feb 6 '13 at 23:16
It works for me. –  Jens Feb 7 '13 at 0:39
I copied your code and didn't work. Can you posted all code which is working on your computer exactly as it is –  Pipe Feb 7 '13 at 16:29
It's all there. What is the error? Did you make sure to initialize all the required functions from the linked answer? I can't just copy all that again. –  Jens Feb 7 '13 at 18:07
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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