4
$\begingroup$

I am using here some random contour plot as an example. I have this ContourPlot:

ContourPlot[Sin[3 x + y^2], {x, -3, 3}, {y, -3, 3}, 
  ColorFunction -> "TemperatureMap", PlotRange -> {-1, 1}]

I have the TemperatureMap in ColorFunction which takes color from red to blue. However, some referee asks me to implement only the "blue" part of TemperatureMap, I tried to play with Rescale but I never remove completely the "red" part.

If we can see the value of color in number, Red can be 0 and Blue equals to 1. I just want the color between 0.5 to 1. Google didn't give me answers ..

Thank you

$\endgroup$
3
  • $\begingroup$ ColorFunction -> "Blue" will give only the blue part. $\endgroup$ Commented Nov 29, 2021 at 16:31
  • $\begingroup$ ContourPlot[Sin[3 x + y^2], {x, -3, 3}, {y, -3, 3}, ColorFunction -> (ColorData["TemperatureMap"][ Rescale[#, {-1, 1}, {0, .5}]] &), PlotRange -> {-1, 1}, ColorFunctionScaling -> False]? $\endgroup$
    – kglr
    Commented Nov 29, 2021 at 20:39
  • $\begingroup$ @DanielHuber But ColorFunction->"Blue" is not a gradient. However the rescaling from the comments of the answer is perfect. @kglr, it's almost what I wanted but with your comment, we kept a little bit the "yellow" part coming from the red part of the TemperatureMap. $\endgroup$
    – G. Sophys
    Commented Nov 30, 2021 at 10:48

1 Answer 1

5
$\begingroup$

Not sure exactly what you mean by "only the blue part". You can experiment with this

ContourPlot[Sin[3 x + y^2], {x, -3, 3}, {y, -3, 3},
 ColorFunction -> (ColorData["TemperatureMap"][Rescale[#, {.5, 1}]] &),
 PlotRange -> {-1, 1},
 ColorFunctionScaling -> False]

Change the {.5, 1} to select parts of the color gradient.

enter image description here

$\endgroup$
5
  • $\begingroup$ Hum, that was I tested before, but there is no shade of blue. Here there is only one or two shade of blue. For example if you rescale from {-1,1 }, you will find a lot of shades of blue before to coming to the red color. They ask me to have something like for example the "DeapSeaColors" ColorFunction, with several shades of blue, but if I can have them from TemperatureMap. $\endgroup$
    – G. Sophys
    Commented Nov 29, 2021 at 16:41
  • $\begingroup$ Okay I played with the {.5, 1} , I also changed the CorlorFunctionScaling in True. I thought that I can choose only value between 0 and 1. I currently have what I wanted, thank you ! $\endgroup$
    – G. Sophys
    Commented Nov 29, 2021 at 16:45
  • $\begingroup$ Don't know enough about scaling, but try: ContourPlot[ Sin[3 x + y^2] , {x, -3, 3}, {y, -3, 3} , PlotRange -> {-1, 1} , ColorFunctionScaling -> True , ColorFunction -> (ColorData["TemperatureMap"][ Rescale[#, {0, 2.4}]] &) , PlotLegends -> Automatic ] $\endgroup$
    – Syed
    Commented Nov 29, 2021 at 17:00
  • $\begingroup$ @Syed Yes this rescale works perfectly for this function. Actually directly when I have the info that we can rescale more that between 0 to 1 helped me a lot and I found the perfect rescale for the referee $\endgroup$
    – G. Sophys
    Commented Nov 30, 2021 at 10:47
  • $\begingroup$ @G.Sophys In addition to scaling of colors and mapping them onto a range, I was not sure about reds being at 0, and blues at 1.1 (so briefly tried to invert the scale as well...) and therefore didn't have the confidence to offer an answer, but I am glad it has worked for your referees and you. $\endgroup$
    – Syed
    Commented Nov 30, 2021 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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