具有分类x轴的rcharts nvd3折线图 [英] rcharts nvd3 linechart with categorical x axis

查看:72
本文介绍了具有分类x轴的rcharts nvd3折线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用nvd3和分类xaxis用rcharts绘制线图?我正在尝试做的事情将与ggplot2看起来像这样:

How can I a draw a linechart with rcharts using nvd3 and a categorical xaxis? What I'm trying to do would look with ggplot2 like this:

library(ggplot2)
dat <- data.frame(expand.grid(group = letters[1:3], x = letters[4:6]), y = rnorm(9))
ggplot(dat, aes(x = x, y = y, group = group, color = group)) + geom_line()

我尝试过:

library(rCharts)
nPlot(y ~ x, group = 'group', data = dat, type = 'lineChart')

我知道我可以将x更改为数字变量,但是xaxis标签将无法正确书写.

I know that I could change x to a numeric variable, but then the xaxis labels would not be correctly written.

推荐答案

这是您要的吗?

foo <- hPlot(x = "x", y = "y", groups = "group", data = dat, type = "line")
foo

这篇关于具有分类x轴的rcharts nvd3折线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆