0

Trying to make colorful columns in highcharter library in R, but could not find a right code. Here is a part of my code, without titles, subtitles - isn't necessary)

> highchart()%>%
+ hc_add_series(data,"column",hcaes(x=Brand, y=Power), name="name")%>%

data (for example):

# A tibble: 4 × 3
  Brand    Power Sprint
  <chr>    <dbl>  <dbl>
1 BMW        181      6
2 Mercedes   179      7
3 Audi       180      8
4 VW         150      9

Thanks for your comments

Raigor
  • 1
  • 1
  • Welcome on SO! While titles and subtitles are indeed unnecessary it would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. If you want to post your data type `dput(NAME_OF_DATASET)` into the console and copy the output into your post. If your dataset has a lot of observations you could do `dput(head(NAME_OF_DATASET, 10))` for just the first ten rows of data. – stefan Jan 29 '22 at 21:01
  • @stefan Hi! Added a data-set for example, ty for comment – Raigor Jan 29 '22 at 21:48
  • @Raigor You could create a vector of colors, something like: `cols <- c("#de3163", "#9fe2bf", "#ccccff", "#ff7f50")` and then include these colors in `hcaes` in your code, something like: `...hcaes(x = Brand, y = Power, color = cols)...` Does that give you what you needed? – Ben Jan 30 '22 at 17:10
  • @Ben ty, that's exactly what I need! I thought, that there is an option like `color=multicolor` or `color=colorvar` - more logic in my opinion. – Raigor Jan 31 '22 at 08:16

0 Answers0