Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing colorants with Scales #1437

Closed
Mattriks opened this issue May 13, 2020 · 0 comments · Fixed by #1438
Closed

Mixing colorants with Scales #1437

Mattriks opened this issue May 13, 2020 · 0 comments · Fixed by #1438

Comments

@Mattriks
Copy link
Member

Gadfly currently allows "1 scale per aesthetic", but this causes issues when using some layers with a scaled color aesthetic, and some layers with specified colorants. In the example below plot p1 works, but plot p2 fails. Plot p2 could be fixed by better handling of Colorants in Scale.color_continuous (and more generally in Scale.color_discrete). This would also help other issues (e.g. #1191). If you think this is good, I'll put in a PR.

D = [DataFrame(x=rand(20), y=rand(20), v=g) for g in ["Group1", "Group2"]]
cs = [colorant"blue", colorant"green"]

p1 = plot( Coord.cartesian(fixed=true),
      layer((x,y)->x+y, 0, 1.0, 0, 1.0),
      layer(D[1], x=:x, y=:y, Theme(default_color=cs[1])),
      layer(D[2], x=:x, y=:y, Theme(default_color=cs[2]))
)
p2 = plot( Coord.cartesian(fixed=true),
      layer((x,y)->x+y, 0, 1.0, 0, 1.0),
      layer(D[1], x=:x, y=:y, color=cs[1:1]),
      layer(D[2], x=:x, y=:y, color=cs[2:2])
)

draw(PNG(), p2) # fails
draw(PNG(), p1) 

colorants_with_Scales

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant