我想通过rcharts说服morris显示图形标题和轴标签(x和y轴的名称)。没有成功。下面的例子。
require(rCharts)
tmp <- data.frame(a=c(1, 2, 3, 4, 5),
b=c(0.1, 0.2, 0.3, 0.4, 0.5),
c=c(0.2, 0.3, 0.4, 0.5, 0.6))
morrisPlot <- mPlot(x="a", y=c("b", "c"), data=tmp,
type="Line", pointSize=4, parseTime=FALSE, hideHover="auto")
morrisPlot$set(height=500) # works
morrisPlot$set(width=500) # works
#morrisPlot$xAxis(axisLabel="a") # Error
#morrisPlot$yAxis(axisLabel="b") # Error
morrisPlot$set(title="Some Title") # doesn't show
morrisPlot
o如何正确设置和显示图表标题和轴名称/标签?
由于沮丧:我对morris感到失望,因为基本上让我的浏览器在尝试绘制简单的多线图时反应迟钝(如上例所示,它有点复杂,数据点也更多)。有其他支持多线图的库(有示例)吗?我的意思是我在不同的列中有数据(没有分组)?
这可能不会直接解决您的问题,但应为您提供有关MorrisJS替代产品的指导。
require(rCharts)
tmp <- data.frame(
a = c(1, 2, 3, 4, 5),
b = c(0.1, 0.2, 0.3, 0.4, 0.5),
c = c(0.2, 0.3, 0.4, 0.5, 0.6)
)
options(stringsAsFactors = F)
library(reshape2)
tmp_m = melt(tmp, id = "a")
library(rCharts)
# NVD3
nPlot(value ~ a, group = 'variable', data = tmp_m, type = 'lineChart')
# Polychart
rPlot(value ~ a, color = 'variable', data = tmp_m, type = 'line')
# Highcharts
hPlot(value ~ a, group = 'variable', data = tmp_m, type = 'line')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句