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

color by different group variables #180

Closed
haohua opened this issue Sep 13, 2016 · 3 comments
Closed

color by different group variables #180

haohua opened this issue Sep 13, 2016 · 3 comments
Labels

Comments

@haohua
Copy link

haohua commented Sep 13, 2016

Hi,

I am trying to create some line charts with grouping and coloring by different variables.

Right now, the color is defined by the group or series. Each series of lines are going to have different color. For example, in the following "citytemp" example, all the Tokyo dots are having one color, while all the London are having another color.

However, I want to color the lines by another column of data, not the series definition. For example, I color the lines by the "SpringSummer" column created below, (we can change the shape of each series to identify the unique series),

Is there any quick examples I can follow? Thank you

library(highcharter)
data(citytemp)
citytemp$SpringSummer = rep( F,nrow(citytemp) )
citytemp$SpringSummer[1:6] = T
hc <- highchart() %>%
hc_xAxis(categories = citytemp$month) %>%
hc_add_series(name = "Tokyo", data = citytemp$tokyo) %>%
hc_add_series(name = "London", data = citytemp$london) %>%
hc_add_series(name = "Other city",
data = (citytemp$tokyo + citytemp$london)/2)

hc

@jbkunst
Copy link
Owner

jbkunst commented Sep 13, 2016

Hi @haohua,

Do you want something like this http://blacklabel.github.io/multicolor_series/?

@haohua
Copy link
Author

haohua commented Sep 13, 2016

Yes. It is more like in ggplot2, you have "group" variable, and "color" variable.
I am guessing in the highcharter, we need to create individual data series for each of the unique combination of the "group" x "color".
Am I understanding this correctly?

thank you

@jbkunst
Copy link
Owner

jbkunst commented Sep 13, 2016

Yep, same as you said.

Highcharter is not so clever as ggplot2.

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

No branches or pull requests

2 participants