-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Unable to use ColorSchemes.jl to set a the colorscale when plotting with a dataframe #446
Comments
In getting started, https://plotly.com/julia/getting-started/ with PlotlyJS.jl, paragraph ColorSchemes.jl, we can read:
respectively:
you'll plot the same colors and color order. |
@empet I am unable to produce the expected behaviour using your solution. Using a more familiar palette (viridis), either method still renders with the default color scheme:
or
|
In your examples there are 10 traces, and it's impossible to map the color values from a trace to a single color from the
Now you can retrieve the number of traces as follows:
and inspect the trace definitions by printing their
No matter what colorscale are you setting or commenting out the line
the lines in the above fig will be plotted by the colors in the |
Thanks for this. So it seems that based on this function, the
Is it possible to change the behaviour so that the above code will produce an equivalent output to the below following (taken from #292 which successfully uses regularly spaced discrete samples from
P.S. I changed to |
Meanwhile I succeeded with a workaround, consisting in two functions: one that defines a colorway of 10 colors from a continuous colorscale, and another that replaces the default colorway, by the new one
and the same plot with:
The last code must be run two times because after the first run it displays the default colorway. |
A better function, that creates a colorway of equally "spaced" n colors, from a colorscale, is this one:
By your definition:
the colorway contains more than 10 colors, but not the lighter colors from viridis, and so your first from those 10 colors are almost indistinguishable. Setting in the function above, the exact number of needed colors, the colorway contains distinguishable colors, from the darkest to the lightest one. |
It is extremely useful to be able to set the colorscale when using PlotlyJS for a dataframe with discrete groups, eg:
Specifically I would like to be able to choose one of the colorscales from ColorSchemes.jl for the different groups in the dataframe.
In the documentation for Plotly in Julia, there are few examples showing usage of the
marker.colorscale
property, and my usage of the property is proving ineffective. I cannot find any examples help me in this case. The closest I could find to usingColorSchemes.jl
withPlotlyJS.jl
is the example in issue #292, but this doesn't translate to the dataframes case.The following works, as per the example:
But the following doesn't work, reverting to the default colorscale:
How can I recreate the first picture using the dataframes syntax?
The text was updated successfully, but these errors were encountered: