Tag Info

Hot answers tagged

7

You already receive great answers concerning the colors, but your random generator confuses me. It is not uniform in the annulus and it's not efficient. I propose the following short and fast generator randomInAnnulus[R1_, R2_, n_] := Transpose@{# Cos@#2, # Sin@#2} &[Sqrt@RandomReal[{R1, R2}^2, n], RandomReal[2 π, n]]; pts = randomInAnnulus[1, 2, ...


5

You have inverted Piecewise arguments. Here is the right form: data = {0.34, 0.04, 1.07, -0.54, -2.4, 0.44}; color=Piecewise[{{Green,# >= 0}}, Red] &; BarChart[data ,ChartLayout -> "Stepped" ,BarSpacing -> None ,ColorFunction -> color ,ColorFunctionScaling -> False ] Now it works: I personaly ...


5

something like this? ImageApply[ If[ # < .5, {1, 0, 0}, {0, 1, 0}] &, ExampleData[{"TestImage", "Gray21"}] ] another example, looking again I guess you want to leave gray outside the specified ranges. ImageApply[Piecewise[{ {{1, 0, 0}, .1 < # < .3}, {{0, 0, 1}, .6 < # < .7}, {{#, #, #}, True}}] &, ...


4

R1 = 2; R2 = 3; t = Table[f[], {10000}]; vc = If[Times @@ # <= 0, Blue, Red] & /@ t; Use Graphics with VertexColors: Graphics[Point[t, VertexColors -> vc], Axes -> True, AspectRatio -> Automatic] Split the data based on Sign [x y] and use PlotStyle: t2 = Pick[t, Sign[Times @@@ t], #] & /@ {1, -1}; ListPlot[t2, AspectRatio -> ...


4

EDIT Thank you for comment from ybeltukov: Exclusions->None: fun[b_, x_] := 1/(2 b)*(Abs[x]^2 - Max[Abs[x] - b, 0]^2) Legended[ParametricPlot[{u, fun[a, u]}, {u, -2, 2}, {a, 0, 1}, ColorFunction -> {ColorData["Rainbow"][#4] &}, Exclusions -> None, ImageSize -> 500], BarLegend["Rainbow"]]


3

I think the key is Binarize but I couldn't figure out a good way to overlay colored parts on a grayscale image so this is rather hackish. At least it is quite a bit faster than your method: colorize2[image_, α_, β_, γ_, θ_] := ColorCombine[{ ImageSubtract[ImageAdd[img, #1], #2], ImageSubtract[ImageAdd[img, #2], #1], ImageSubtract[img, ##]}] ...


2

By default, most plotting function re-scale the values they compute to lie inbetween 0 and 1, then this value is passed to the colour function. TemperatureMap is white for 0.5, so the white colour will correspond to the average of the minimum and maximum values that DensityPlot computed in the given plot domain. You need to override this automatic scaling ...


2

For example: Plot3D[Exp[-x^2 - y^2] - Exp[-(x - 1)^2 - (y - 1)^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (ColorData["TemperatureMap", #3 + .5] &), ColorFunctionScaling -> False]


2

Here is a first pass at this problem. img = Import["http://i.stack.imgur.com/wwHZe.jpg"]; getHue = First[DominantColors[#, 1][[1]] ~ToColor~ Hue] &; hues = Map[getHue, ImagePartition[img, 40], {2}]; plot = Map[Hue, hues, {2}] // ArrayPlot I tried to use ClusteringComponents to further quantize these hues but I got a bad result. Edit: After a ...


2

Try this: Graphics[{If[Times @@ # > 0, Red, Blue], Point[#]} & /@ A] which produces this: I used R1 = 1.0; R2 = 0.5; as the constants. A is the list of random points. This plotting method is pretty slow; unfortunately ListPlot requires Joined -> True for ColorFunction to be applied, and for random points it just looks like a mess.


2

To find the explanation for the different colors, just highlight the symbol of interest, and go to the menu item Help > Why the Coloring?.... This will tell you that those symbols whose value has not been defined will appear blue by default. On the other hand, f for example starts out blue before you press shift-return, and changes to black once you ...


1

You have to use SameQ (===): test[lcolor_: Red] := Module[{}, Red === lcolor] test /@ {RGBColor[1, 0, 0], Red, Blue} {True, True, False} For a full explanation read the Details sections for Equal and SameQ



Only top voted, non community-wiki answers of a minimum length are eligible