New answers tagged

1

Cases[fplot, RGBColor[x_, y_, z_] :> {x, y, z}, Infinity] {{0.368417, 0.506779, 0.709798}, {0.880722, 0.611041, 0.142051}, {0.560181, 0.691569, 0.194885}, {0.922526, 0.385626, 0.209179}}


7

The following is a universal solution which extracts RGB color values assigned to the Line primitives of a plot generated by built-in plotting functions of Mathematica 10: Cases[fplot, {___, c_Directive, __Line} :> ColorConvert[c, RGBColor], Infinity] // InputForm {RGBColor[0.368417, 0.506779, 0.709798, 1.], RGBColor[0.880722, 0.611041, 0.142051, ...


2

If you are using Mathematica version 9.0 or later, you can use the PlotLegends option as shown in the documentation and in Lukas's answer (beat me to it by 2 minutes). But if you are using an older version you have to resort to the PlotLegends package (I know it's confusing), << PlotLegends` With[{arrayData = Array[Sin[.01 π (#1 - 2 #2)] &, {100, ...


3

This is how you add a color legend to your ListContourPlot (also true for similar types of plots). This is by the way the third example in the ListContourPlot documentation. Of course, the crucial part is the PlotLegends option. data = Table[{x = RandomReal[{-2, 2}], y = RandomReal[{-2, 2}], Sin[x y]}, 1000}]; ListContourPlot[ data, ColorFunction -> ...


2

I don't think it's possible to extract such information from an already evaluated plot. Plot returns a Graphics object and very little meta-information is stored. We can see this by inspecting with InputForm. InputForm[Plot[1, {x, 0, 1}, ColorFunction -> Hue, PlotPoints -> 2]] Graphics[{GraphicsComplex[{{1.*^-6, 1.}, {0.999999, 1.}, {0.5, 1.}}, ...


4

This doesn't allow the extraction and reconstruction of the unknown ColorFunction, but it does allow to override it with an exact duplicate that is transparent, plt1 = Plot[Sin[x], {x, 0, 2 Pi}, ColorFunction -> (#^2 &), ImageSize -> 300]; plt2 = Plot[Sin[x], {x, 0, 2 Pi}, ColorFunction -> (Hue[#^2] &), ImageSize -> 300]; plt3 = ...


3

In this case, the KnotData evaluates directly to a parametric curve, KnotData["Trefoil", "SpaceCurve"] (* {Sin[#1] + 2 Sin[2 #1], Cos[#1] - 2 Cos[2 #1], -Sin[3 #1]} & *) so that no sampling is necessary. ParametricPlot3D[ KnotData["Trefoil", "SpaceCurve"][t], {t, 0, 2 \[Pi]}, PlotRange -> All, Axes -> None, Boxed -> False, ViewPoint ...


4

It can be done by applying ColorData["TemperatureMap"] to a piecewise function that rescales the intervals -100 to 0 and 0 to 10 separately. cf[u_] = ColorData["TemperatureMap"] @ Piecewise[ {{Rescale[u, {-100, 0}, {0., .5}], -100 < u < 0}, {Rescale[u, {0, 10}, {.5, 1.}], 0 <= u <= 10}}]; DensityPlot[x, {x, -100, 10}, {y, ...


8

What you need is a nonlinear function to map to, one that is close to zero for values near x=-100, reaches 1/2 at x=0, and 1 at x=10. This works, Plot[Exp[x Log[2]/10]/2, {x, -100, 10}, PlotRange -> All] So applying this to a ColorFunction cf = ColorData["TemperatureMap"][Exp[# Log[2]/10]/2] & BarLegend[{cf, {-100, 10}}] Using a 3-point ...


2

Yeah, I see the same behavior on MMA 10.4: something funny is going on here. This is really an extended comment rather than an answer. You could define your own graylevel function that also prints the values passed to it for evaluation, to check what is going on: Clear[gray] gray[x_] := Module[{}, Print[x]; RGBColor[x, x, x]] and use in MatrixPlot: ...


2

Perhaps an acceptable solution is to convert your plot to an image and apply very light filtering on it. At least to my eye, a median filter seems fit the bill here: it retains as much sharpness as possible, while "blending points" to form more uniform swaths Using your data (notice that I removed your PlotRange option from Graphics for convenience in ...



Top 50 recent answers are included