FreeQ[{0, 0}, Except[0]]?
4:59 AM
4 hours later…
5 hours later…
2 hours later…
4:48 PM
@R.M hello; I am interested in your post mathematica.stackexchange.com/questions/2058/… I would like to write a function which could post process a given ContourPlot or DensityPlot and add a color bar as you did in that post but with the proper scaling
1 hour later…
6:07 PM
7:09 PM
@R.M I have started with this `
Clear[colorbar]
colorbar[colorFunction_: Automatic, divs_: 150] :=
DensityPlot[y, {x, 0, .1}, {y, 0, 1}, AspectRatio -> Automatic,
PlotRangePadding -> 0, PlotPoints -> {2, divs}, MaxRecursion -> 0,
FrameTicks -> {None, Automatic, None, None},
ColorFunction -> colorFunction]
ColorBar[plot_, cf_: "Heat"] :=
With[{size = 300}, Row[Show[#, ImageSize -> {Automatic, size},
ImagePadding -> 20] & /@ {plot, colorbar[cf]}]]
ContourPlot[2 Sin[Norm[{x, y}]], {x, 0, 10}, {y, 0, 10}, ColorFunction -> "Heat"] // ColorBar[#, "Heat"] &`
Clear[colorbar]
colorbar[colorFunction_: Automatic, divs_: 150] :=
DensityPlot[y, {x, 0, .1}, {y, 0, 1}, AspectRatio -> Automatic,
PlotRangePadding -> 0, PlotPoints -> {2, divs}, MaxRecursion -> 0,
FrameTicks -> {None, Automatic, None, None},
ColorFunction -> colorFunction]
ColorBar[plot_, cf_: "Heat"] :=
With[{size = 300}, Row[Show[#, ImageSize -> {Automatic, size},
ImagePadding -> 20] & /@ {plot, colorbar[cf]}]]
ContourPlot[2 Sin[Norm[{x, y}]], {x, 0, 10}, {y, 0, 10}, ColorFunction -> "Heat"] // ColorBar[#, "Heat"] &`
3 hours later…
10:20 PM
@chris To do that, you'll have to change
colorbar a bit to accept a min and max values for the range. For example:
Clear[colorbar]
colorbar[{min_, max_}, colorFunction_: Automatic, divs_: 150] :=
DensityPlot[y, {x, 0, 0.1}, {y, min, max}, AspectRatio -> Automatic,
PlotRangePadding -> 0, PlotPoints -> {2, divs}, MaxRecursion -> 0,
FrameTicks -> {None, Automatic, None, None},
ColorFunction -> colorFunction]
There are several ways in which you can get the min/max values from a plot. For a simple line plot, it might be as simple as inspecting the
FullForm and picking out the max value from the Line[...] part.
But a general way to do this would be using
EvaluationMonitor to sow the values of the function, then take the min/max of that and feed it to the modified colorbar function
« first day (234 days earlier) ← previous day next day → last day (255 days later) »

