GiovineItalia / Gadfly.jl

Crafty statistical graphics for Julia.
http://gadflyjl.org/stable/
Other
1.9k stars 251 forks source link

Gradient Scale and color #723

Closed dj-kim closed 5 years ago

dj-kim commented 9 years ago

With regard to gradient scale, I got a problem.

When I set the gradient range from 0 to 20 It work well. But in case of set the range from 4 to 16, the gradient scale doesn't changed. I attached picture about that.

Also, To make continuous color map, I selected 5 color from CN array. Then is it possible to using all CN color rather than select few color?

cn = linspace(Color.HSV(0,1,1),Color.HSV(250,1,1),150)

I hope to using color like below.

Scale.ContinuousColorScale(minvalue=0 , maxvalue=20 , Scale.lab_gradient( cn[:])),

But It doesn't work

Scale.ContinuousColorScale(minvalue=0 , maxvalue=20 , Scale.lab_gradient( cn[1],cn[30],cn[60],cn[90],cn[120],cn[150])), >> work Scale.ContinuousColorScale(minvalue=4 , maxvalue=16 , Scale.lab_gradient( cn[1],cn[30],cn[60],cn[90],cn[120],cn[150])), >> Gradient scale doesn't changed.

map2 =plot(

layer(df, x="x", y="y", color="vel", Theme(colorkey_swatch_shape=:square,default_point_size=(1.5mm),highlight_width=(0.1mm)), Geom.point),

      layer(df2, x="x", y="y", color="vel", Theme(colorkey_swatch_shape=:square,default_point_size=(1.0mm),highlight_width=(0.1mm)), Geom.point),
        Theme(panel_fill=color("white"),panel_stroke=color("black")),  Guide.colorkey("V(km/s)"),
       Scale.ContinuousColorScale(minvalue=0 , maxvalue=20 , Scale.lab_gradient(
        cn[1],cn[30],cn[60],cn[90],cn[120],cn[150])),
       Scale.x_continuous(minvalue=-440, maxvalue=-400),Scale.y_continuous(minvalue=-50, maxvalue=0),Coord.cartesian(xflip=true),
       Guide.xlabel("R.A. offset (mas)"),Guide.ylabel("Dec. offset (mas)"),Guide.title("42"),
      )

2015-10-10 1 13 41 2015-10-10 1 20 08

protogeezer commented 9 years ago

On Oct 9, 2015, at 10:26 PM, DJ-kim notifications@github.com wrote:

With regard to gradient scale, I got a problem.

When I set the gradient range from 0 to 20 It work well. But in case of I set from 4 to 16, the gradient scale doesn't changed.

I found this same problem with the plots I’m doing for a paper - it bugged me enough that I’ve been working on a patch to change the behavior of gadfly to use the values that are supplied by the user - would that solve your problem too?

Also, To make continuous color map, I selected 5 color from CN array. Then is it possible to using all CN color rather than select few color?

What happens if you just give two color values - the two at the end of the color range you want to use for the gradient? I’ve been working on rectbin and hist2d plots…

maybe there should be two ways of supplying color values for the gradient. (1) just two values maybe calling that a range, and (2) supplying a list of colors as it is now?

cn = linspace(Color.HSV(0,1,1),Color.HSV(250,1,1),150)

I hope to using color like below.

Scale.ContinuousColorScale(minvalue=0 , maxvalue=20 , Scale.lab_gradient( cn[:])),

But It doesn't work

Scale.ContinuousColorScale(minvalue=0 , maxvalue=20 , Scale.lab_gradient( cn[1],cn[30],cn[60],cn[90],cn[120],cn[150])), >> work Scale.ContinuousColorScale(minvalue=4 , maxvalue=16 , Scale.lab_gradient( cn[1],cn[30],cn[60],cn[90],cn[120],cn[150])), >> Gradient scale doesn't changed.

map2 =plot(

layer(df, x="x", y="y", color="vel", Theme(colorkey_swatch_shape=:square,default_point_size=(1.5mm),highlight_width=(0.1mm)), Geom.point),

layer(df2, x="x", y="y", color="vel", Theme(colorkey_swatch_shape=:square,default_point_size=(1.0mm),highlight_width=(0.1mm)), Geom.point), Theme(panel_fill=color("white"),panel_stroke=color("black")), Guide.colorkey("V(km/s)"), Scale.ContinuousColorScale(minvalue=0 , maxvalue=20 , Scale.lab_gradient( cn[1],cn[30],cn[60],cn[90],cn[120],cn[150])), Scale.x_continuous(minvalue=-440, maxvalue=-400),Scale.y_continuous(minvalue=-50, maxvalue=0),Coord.cartesian(xflip=true), Guide.xlabel("R.A. offset (mas)"),Guide.ylabel("Dec. offset (mas)"),Guide.title("42"), )

— Reply to this email directly or view it on GitHub.

simleb commented 8 years ago

Same issue here. I think the culprit is optimize_ticks which overrides the minvalue and/or maxvalue specified in the colorscale.