2 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

I have some function of two variables (which happens to be the error in some approximation I'm interested in). I'd like to get a density plot of the function, such that in regions when the function is zero, the plot is white, and then there is shading in two different colours when it is positive or negative. Here is an example of what I'd like to get.

An example

When the range is not symmetric around zero, by default zero no longer corresponds to white. It's not too hard to fix this case-by-case, by looking at what the range of the function is and changing the ColorFunction accordingly:

ColorFunction -> (ColorData["RedGreenSplit", .5 + #/myScaling] &), ColorFunctionScaling -> False

But this requires that I first somehow work out what value of myScaling to plug in manually each time. It would be nice to be able to do this automatically: get Mathematica to do what it usually does with ColorFunctionScaling, but with the constraint that the chosen range is centred at 0.

[Related: Change the colour scheme in DensityPlots to make the zero whiteChange the colour scheme in DensityPlots to make the zero white]

I have some function of two variables (which happens to be the error in some approximation I'm interested in). I'd like to get a density plot of the function, such that in regions when the function is zero, the plot is white, and then there is shading in two different colours when it is positive or negative. Here is an example of what I'd like to get.

An example

When the range is not symmetric around zero, by default zero no longer corresponds to white. It's not too hard to fix this case-by-case, by looking at what the range of the function is and changing the ColorFunction accordingly:

ColorFunction -> (ColorData["RedGreenSplit", .5 + #/myScaling] &), ColorFunctionScaling -> False

But this requires that I first somehow work out what value of myScaling to plug in manually each time. It would be nice to be able to do this automatically: get Mathematica to do what it usually does with ColorFunctionScaling, but with the constraint that the chosen range is centred at 0.

[Related: Change the colour scheme in DensityPlots to make the zero white]

I have some function of two variables (which happens to be the error in some approximation I'm interested in). I'd like to get a density plot of the function, such that in regions when the function is zero, the plot is white, and then there is shading in two different colours when it is positive or negative. Here is an example of what I'd like to get.

An example

When the range is not symmetric around zero, by default zero no longer corresponds to white. It's not too hard to fix this case-by-case, by looking at what the range of the function is and changing the ColorFunction accordingly:

ColorFunction -> (ColorData["RedGreenSplit", .5 + #/myScaling] &), ColorFunctionScaling -> False

But this requires that I first somehow work out what value of myScaling to plug in manually each time. It would be nice to be able to do this automatically: get Mathematica to do what it usually does with ColorFunctionScaling, but with the constraint that the chosen range is centred at 0.

[Related: Change the colour scheme in DensityPlots to make the zero white]

1
source | link

DensityPlot colours symmetric around zero

I have some function of two variables (which happens to be the error in some approximation I'm interested in). I'd like to get a density plot of the function, such that in regions when the function is zero, the plot is white, and then there is shading in two different colours when it is positive or negative. Here is an example of what I'd like to get.

An example

When the range is not symmetric around zero, by default zero no longer corresponds to white. It's not too hard to fix this case-by-case, by looking at what the range of the function is and changing the ColorFunction accordingly:

ColorFunction -> (ColorData["RedGreenSplit", .5 + #/myScaling] &), ColorFunctionScaling -> False

But this requires that I first somehow work out what value of myScaling to plug in manually each time. It would be nice to be able to do this automatically: get Mathematica to do what it usually does with ColorFunctionScaling, but with the constraint that the chosen range is centred at 0.

[Related: Change the colour scheme in DensityPlots to make the zero white]