如何为条形图着色&旋转echarts4r中的轴标签
我有基本的DF,我正在尝试为每个栏添加不同的颜色。根据E_Color文档,我们需要提供颜色的向量,但它不起作用,我只从矢量中获得一种颜色。此外,我想旋转45dg x轴标签,但尚未找到任何解决方案。这两个主题的任何帮助都非常感谢。
谢谢
亚当
df <- data.frame(
x = c('AAA','BBB','CCC','DDD','EEE','FFF','GGG'),
y = c(10,20,30,40,50,60,70)
)
my_colors <- brewer.pal(7, "GnBu")
df %>% e_chart(x) %>% e_bar(y) %>% e_color(my_colors) %>% e_x_axis(label = list(rotate = 45))
I have basic df and I'm trying to add different color for each bar. According to e_color doc we need to provide a vector of colors but it doesn't work, I'm getting only one color from the vector. Additionally I'd like to rotate by 45dg x axis label but haven't found any solution yet. Any help with both topics much appreciated.
Thanks
Adam
df <- data.frame(
x = c('AAA','BBB','CCC','DDD','EEE','FFF','GGG'),
y = c(10,20,30,40,50,60,70)
)
my_colors <- brewer.pal(7, "GnBu")
df %>% e_chart(x) %>% e_bar(y) %>% e_color(my_colors) %>% e_x_axis(label = list(rotate = 45))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要将颜色分配给名为
颜色
的数据框架。然后,您可以使用e_add
与“ itemStyle”
添加它们。要旋转标签,您应该使用axislabel
像这样:output:
First of all you need to assign your colors to your data frame named
color
. Then you can add them by usinge_add
with"itemStyle"
. To rotate your labels you should useaxisLabel
like this:Output: