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

Husl palette equivalent #876

Closed
Zaf4 opened this issue Sep 12, 2023 · 4 comments
Closed

Husl palette equivalent #876

Zaf4 opened this issue Sep 12, 2023 · 4 comments
Assignees
Milestone

Comments

@Zaf4
Copy link

Zaf4 commented Sep 12, 2023

I tried to find the default color palette of R's ggplot (husl_palette in seaborn) in lets-plot but I couldn't. It is a great palette for categorical data. So, I think it would be a great addition to lets-plot.

Here is the link to the seaborn one: https://seaborn.pydata.org/generated/seaborn.husl_palette.html
And this to the R's ggplot: https://scales.r-lib.org/reference/hue_pal.html

FYI, I already tried following existing palettes.

diverging = ["BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral"]
qualitative = ["Accent", "Dark2", "Paired", "Pastel1", "Pastel2", "Set1", "Set2", "Set3"]
sequential = ["Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd"]

and the viridis ones,
viridis = ["A","B","C","D","E","turbo","twilight"]

and none of them looks like ggplot2's default palette.

@alshan alshan added this to the New milestone Sep 12, 2023
@alshan
Copy link
Collaborator

alshan commented Sep 12, 2023

Have you tried "hue" scales?
https://lets-plot.org/pages/api/lets_plot.scale_color_hue.html

@Zaf4
Copy link
Author

Zaf4 commented Sep 15, 2023

I tried it after your suggestion. They use the same principle but somehow with the same h,c,l values resulting palettes are very different.

@Zaf4
Copy link
Author

Zaf4 commented Sep 16, 2023

Here is the R's ggplot default.
R
Then, seaborn using 'husl'
seaborn
Lastly, from lets-plot + scale_fill_hue()
lets_plot

Obviously, seaborn and ggplot produce very similar colors. But, lets-plot scale_hue produces different set of colors even with the same parameters.

Difference might be scale_hue documentation says " Qualitative color scale with evenly spaced hues for color aesthetic."

While husl_palette says "This function is similar to hls_palette(), but it uses a nonlinear color space that is more perceptually uniform."

@alshan
Copy link
Collaborator

alshan commented Sep 17, 2023

You are right, there is significant difference in colors. Likely this is because lets-plot scale_hue uses HSV color space instead of HSL under the hood. Certainly need to be fixed.

@alshan alshan modified the milestones: New, 2023Q4 Sep 29, 2023
@IKupriyanov-HORIS IKupriyanov-HORIS self-assigned this Oct 13, 2023
@Zaf4 Zaf4 closed this as completed Nov 4, 2023
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