1
$\begingroup$

Given a list of ContourPlot:

cp1 = ContourPlot[Sin[x] + Sin[y], {x, -2 \[Pi], 2 \[Pi]}, {y, -2 \[Pi], 2 \[Pi]}];
cp2 = ContourPlot[2*(Sin[x] + Sin[y]), {x, -2 \[Pi], 2 \[Pi]}, {y, -2 \[Pi], 2 \[Pi]}];
cpList = {cp1,cp2}

How can I make the contours (and color steps) for all elements of cpList the same, whilst being able to specify the List of contour magnitudes manually (e.g. Range[-2, 2, 0.5])?


Contours->Range[-4, 4, 0.5] (better than above) does part of the work, but the color-scales arent equal: no equal color scale

$\endgroup$

closed as off-topic by Feyre, MarcoB, happy fish, Edmund, JungHwan Min Nov 29 '16 at 4:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Feyre, MarcoB, happy fish, Edmund, JungHwan Min
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Contours? E.g. Contours -> Range[-2, 2, 0.5] $\endgroup$ – corey979 Nov 23 '16 at 12:29
  • $\begingroup$ @corey979 That's part of it, but the color-scale is not equal. $\endgroup$ – DPF Nov 23 '16 at 12:31
  • 2
    $\begingroup$ @DPF You can use ColorFunction for that $\endgroup$ – Sascha Nov 23 '16 at 12:32
2
$\begingroup$

To make the color scaling equal you have to supply your own ColorFunction and turn off ColorFunctionScaling. Add for instance the options

ColorFunction -> (Blend[{Red, Blue}, Rescale[#, {-3, 3}]] &),
ColorFunctionScaling -> False

to both plots and you get something like

image

where I added plot legends via PlotLegends -> Automatic for reference

$\endgroup$
  • $\begingroup$ That's a good way to do it. The only thing I'd like to have in addition to your solution is equal Legends for all Plots $\endgroup$ – DPF Nov 23 '16 at 12:52
  • $\begingroup$ you mean a common legend shared by both plots? $\endgroup$ – Sascha Nov 23 '16 at 12:55
  • $\begingroup$ I mean each plot has its own legend, but showing the same number-range and colorfunction. $\endgroup$ – DPF Nov 23 '16 at 12:56
  • $\begingroup$ by the way: is there a possibility, to Rescale the existing ColorFunctions? $\endgroup$ – DPF Nov 23 '16 at 13:02
  • 1
    $\begingroup$ @DPF you can create your own custom BarLegend for instance BarLegend[{{Red, Blue}, {-3, 3}}, Range[-3, 3, 0.5]] and use it inside each plot $\endgroup$ – Sascha Nov 23 '16 at 13:04

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