Open phipsgabler opened 6 years ago
The issue here is that the user is wanting a continuous color scale for Geom.contour
, and a discrete color scale for Geom.point
. Currently Gadfly only allows one automatic color scale.
The above plot could be done like this:
theme(x) = style(default_color=parse(Colors.Colorant,x))
g = [:one, :two]
Da = [DataFrame(x=rand(20), y=rand(20), v=g[i]) for i in 1:2]
discrete_colors = ["deepskyblue", "lightgreen"]
p = plot(
layer(x = linspace(0, 1, 100), y = linspace(0, 1, 100), z = (x,y) -> x + y, Geom.contour),
layer(Da[1], x = :x, y = :y, theme(discrete_colors[1]), Geom.point),
layer(Da[2], x = :x, y = :y, theme(discrete_colors[2]), Geom.point),
Coord.cartesian(fixed=true)
)
But, if you want to map Geom.point
to the same color scale as Geom.contour
, that is possible:
Db = vcat([DataFrame(x=rand(20), y=rand(20), v=i) for i in [0.5,1.5]]...)
p = plot(
layer(x = linspace(0, 1, 100), y = linspace(0, 1, 100), z = (x,y) -> x + y, Geom.contour),
layer(Db, x=:x, y=:y, color=:v, Geom.point),
Scale.color_continuous(minvalue=0.0, maxvalue=2.0),
Coord.cartesian(fixed=true)
)
Ah, I didn't realize that this is a clash of scales. I'll figure out something to work around that based on you examples. Thanks!
I was trying to plot two traces of points over a function contour:
But doing so results in an error, which seems to have to do with the
color
argument:The following, leaving out the contour plot or the
color
specification, both work without problems:I use version 0.6.4.