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

Altered colours from subsequent use of a custom palette #701

Closed
sylvaticus opened this issue Feb 23, 2017 · 4 comments
Closed

Altered colours from subsequent use of a custom palette #701

sylvaticus opened this issue Feb 23, 2017 · 4 comments

Comments

@sylvaticus
Copy link

Hello, when trying to plot multiple groups of series from a dataframe and reuse the same colour palette for the individual series, the subsequent series use an "altered" version of the colours:

using DataFrames, Plots, StatPlots
x = [110,120,130,140, 105,115,125,135]
df = DataFrame(
  fruit   = ["orange","orange","orange","orange","banana","banana","banana","banana"],
  year    = [2010,2011,2012,2013,2010,2011,2012,2013],
  prod    = x,
  cons    = x - 20,
  exports = x - 40,
  imports  = x - 60,
)
plotlyjs() # same with pyplot() backend..
mycolors = [:red, :green  ] # same with mycolors = [:yellow, :orange ]
fruits_plot = plot(df, :year, :prod, group=:fruit, linestyle = :solid, linewidth=3, linecolor=:match, color_palette = mycolors)
fruits_plot = plot!(df, :year, :cons, group=:fruit, linestyle = :dot, linewidth=3, linecolor=:match, color_palette = mycolors)
fruits_plot = plot!(df, :year, :exports, group=:fruit, linestyle = :dash, linewidth=3, linecolor=:match, color_palette = mycolors)
fruits_plot = plot!(df, :year, :imports, group=:fruit, linestyle = :dashdot, linewidth=3, linecolor=:match, color_palette = mycolors)

Results in:
fruits_plot

As you can see, the problem is that the subsequent groups of series use the palette with somehow "distorted" (or sometimes inverted) colours.

This is independent from the specific backend used.

@tbreloff
Copy link
Member

tbreloff commented Feb 23, 2017 via email

@sylvaticus
Copy link
Author

sylvaticus commented Feb 23, 2017

In the documentation it is stated that:

color_palette determines the colors assigned when seriescolor == :auto:

If passed a vector of colors, it will force cycling of those colors

This is what I want, as I am using it for a group of series, not for an individual one (and I am using the keywork group)
In fact, it works well on the first usage. The problem is when I add to the same plot other group of series.

Bdw, I did try to set linecolor directly, but it accepts only a scalar, not arrays..

@tbreloff
Copy link
Member

tbreloff commented Feb 23, 2017 via email

@sylvaticus
Copy link
Author

yep, using fruits_plot = plot(df, :year, :prod, group=:fruit, linestyle = :solid, linewidth=3, linecolor=[[:red] [:yellow]]) works, thanks..

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