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

Adding R's color brewer pallet #32

Open
ValentinKaisermayer opened this issue Oct 7, 2019 · 13 comments
Open

Adding R's color brewer pallet #32

ValentinKaisermayer opened this issue Oct 7, 2019 · 13 comments

Comments

@ValentinKaisermayer
Copy link

Would you consider adding the R color brewer pallete

e.g. dark2 pallete

dark2 = [
 RGB(([ 27, 158, 119]/255)...),
 RGB(([217,  95,   2]/255)...),
 RGB(([117, 112, 179]/255)...),
 RGB(([231,  41, 138]/255)...),
 RGB(([102, 166,  30]/255)...),
 RGB(([230, 171,   2]/255)...),
 RGB(([166, 118,  29]/255)...),
 RGB(([102, 102, 102]/255)...)
 ]

image

see Github source

@mkborregaard
Copy link
Member

The colorbrewer palettes (which have nothing to do with R) are added. dark2 has been one of the few that was kept out for some time - but this open PR adds them JuliaPlots/PlotUtils.jl#67

@mkborregaard
Copy link
Member

@ValentinKaisermayer
Copy link
Author

Thank you!

@ValentinKaisermayer
Copy link
Author

ValentinKaisermayer commented Oct 7, 2019

This does not really work:

using Plots, PlotThemes
clibrary(:colorbrewer)
plot(rand(5, 100)', lw=2, palette=:Dark2)

image

The automatically chosen colors are too similar and are hard to distinguish.

@ValentinKaisermayer
Copy link
Author

Especially 2, 3 and 4 in the above plot.

@mkborregaard
Copy link
Member

Did you check out that Pull Request I linked?

@mkborregaard
Copy link
Member

Oh I see it got merged. So this is on master? The colors do look a little off.

@daschw
Copy link
Member

daschw commented Oct 7, 2019

palette = palette(:Dark2) works, but IMO palette = :Dark2 should also. Not sure what's the issue there, maybe a call to distinguishable_colors or something.

EDIT: No it does not, it just uses the default palette, sorry ...

@ValentinKaisermayer
Copy link
Author

The problem seems to be in get_color_palette which is called by plot when the palette argument is supplied.

The following code would produce the correct color palette.

grad = cgrad(:Dark2)
RGBA{Float64}[grad[z] for z in 1:numcolors]

@ValentinKaisermayer
Copy link
Author

zrng = get_zvalues(numcolors) produces a weird, unordered list of values between 0 and 1 which may be beneficial if the underlying cgrad is ordered in some sense. But in this case it is not.

@mkborregaard
Copy link
Member

Yes, we had some discussion about how to best add the categorical palettes, as they are something different from color gradients. We ended up agreeing that we could just include them and it would be fine. Looks like that wasn't correct.

@daschw
Copy link
Member

daschw commented Oct 8, 2019

So, do you think we need a type different from ColorGradient for categorical palettes?

@mkborregaard
Copy link
Member

I think distinguishing between them could be a possibility yes. But a little unsure of the repercussions

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

No branches or pull requests

3 participants