rcharts weird numbers in the y axis

吃可爱长大的小学妹 提交于 2019-12-11 08:33:47

问题


The file to generate the graph can be downloaded from https://db.tt/hHYq0mSA. I'm sharing a link because dput generates a huge output. This is what I'm runing

require(rCharts)
dense<-readRDS("dense.RDS")
nPlot(x = "minutes", y = "FBS", data = dense, type = "lineChart")

This is what I get

What are the numbers (63382626 and 67270968) in the Y axis? how can I make them go away?

Thanks!


回答1:


The strange digits are the final digits of the min and max of y

> options(digits=12)
> min(dense[,2])
[1] 0.000239026338263
> max(dense[,2])
[1] 0.0417486727097

You need to add some formatting rules on the y axis ticks:

require(rCharts)
dense<-readRDS("dense.RDS")
n1 <- nPlot(x = "minutes", y = "FBS", data = dense, type = "lineChart")
n1$yAxis(tickFormat = "#! function(d) {return d3.format(',.2f')(d)} !#")
n1

Aternative you can set the domain of the yaxis and keep the digits

require(rCharts)
dense<-readRDS("../Downloads/dense.RDS")
n1 <- nPlot(x = "minutes", y = "FBS", data = dense, type = "lineChart")
n1$chart(forceY = c(0, 0.05))
n1



来源:https://stackoverflow.com/questions/24494614/rcharts-weird-numbers-in-the-y-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!