Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nvd3散点图,R中有rCharts:改变点的大小?_R_Nvd3.js_Rcharts - Fatal编程技术网

nvd3散点图,R中有rCharts:改变点的大小?

nvd3散点图,R中有rCharts:改变点的大小?,r,nvd3.js,rcharts,R,Nvd3.js,Rcharts,我已经玩了rCharts和nvd3一段时间了。现在我需要一个气泡图,或者至少是一个散点图,其中点的大小取决于数据中的变量。从这个角度来看,这似乎是可能的。rCharts中散点图的示例为: library(rCharts) p1 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart') p1$xAxis(axisLabel = 'Weight') p1 有可能吗?可以使用图表方法,该方法允许您指定大小、颜

我已经玩了rCharts和nvd3一段时间了。现在我需要一个气泡图,或者至少是一个散点图,其中点的大小取决于数据中的变量。从这个角度来看,这似乎是可能的。rCharts中散点图的示例为:

library(rCharts)
p1 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart')
p1$xAxis(axisLabel = 'Weight')
p1

有可能吗?

可以使用
图表
方法,该方法允许您指定
大小
颜色
等。该实现现在有点笨拙,需要您传递一个javascript函数,返回指定大小的列。
##语法来告诉rCharts将内容视为JS文本,而不是在组装负载时将其转换为字符串。可以查看图表

库(rCharts)
p2
p2 <- nPlot(mpg ~ wt, group = 'cyl', size = 'gear', data = mtcars, type = 'scatterChart')
p2$xAxis(axisLabel = 'Weight')
p2
library(rCharts)
p2 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart')
p2$xAxis(axisLabel = 'Weight')
p2$chart(size = '#! function(d){return d.gear} !#')
p2