GiovineItalia / Gadfly.jl

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

colorkey min/max values #1626

Open montyvesselinov opened 1 year ago

montyvesselinov commented 1 year ago

The new version of Gadfly seems to be overriding the min/max values set in color_continuous().

The code below

plot(x=rand(12), y=rand(12), color=rand(12), Scale.color_continuous(minvalue=-1, maxvalue=100)) 

produces a colorkey from -50 to 100.

How to force Gadfly to produce a colorkey from -1 to 100?

DomHin commented 11 months ago

I observe something similar with the colorkey values. Changing from float to int and minvalue maxvalue have no effect anymore.

So my basic advise is actually to use floats with minvalue maxvalue if someone provides these such as in my example p3. For better clarity in some plots this makes sense to have the colorbar ranging from 0.5 to 3.4 or so instead of 0 to 4.

using Gadfly, Colors

y = [0.1, 0.4, 0.9, 0.3, 0.25, 0.53, 1.1, 1.6, 1.9, 2.5]
p1 = plot(x=[1:1:length(y)...], y=[1:1:length(y)...], color=y, Geom.rectbin,
 Scale.color_continuous(colormap=p->RGB(0,p,0)))

y = [0.1, 0.4, 0.9, 0.3, 0.25, 0.53, 1.1, 1.6, 1.9, 2.8]
p2 = plot(x=[1:1:length(y)...], y=[1:1:length(y)...], color=y, Geom.rectbin,
 Scale.color_continuous(colormap=p->RGB(0,p,0)))

p3 = plot(x=[1:1:length(y)...], y=[1:1:length(y)...], color=y, Geom.rectbin,
 Scale.color_continuous(colormap=p->RGB(0,p,0),minvalue=0.1,maxvalue=2.8))

set_default_plot_size(10inch,4inch)
hstack(p1,p2,p3)

Gadfly_colorkey_values

Is there a reason why the values change from floats to ints (p1 -> p2 if some value is larger)