使用R在Canvasxpress中更改Scatter3d的颜色

时间:2017-08-16 19:28:52

标签: javascript r canvas scatter3d

在本网站的第一个例子中(https://cran.r-project.org/web/packages/canvasXpress/vignettes/getting_started.html#scatter-3d-plot),使用R使用canvasxpress包制作了一个三维散点图。

只需复制并粘贴代码即可轻松获得示例中的结果...

data <- t(iris[,1:4])
varAnnot <- as.matrix(iris[,5])
colnames(varAnnot) <- "Species"
canvasXpress(t(data), varAnnot=varAnnot, graphType='Scatter3D', colorBy='Species')

我想知道是否有办法在canvasXpress(t(data), varAnnot=varAnnot, graphType='Scatter3D', colorBy='Species')内传递 像:

这样的论点
canvasXpress(t(data), varAnnot=varAnnot, graphType='Scatter3D', colorBy='Species', colors="rgb(153,204,255)","rgb(204,102,0)","rgb(153,76,0)","rgb(169,131,7)","rgb(153,255,153)","rgb(105,150,150)","rgb(183,120,68)","rgb(131,172,208)","rgb(194,224,118)","rgb(250,220,90)","rgb(255,84,159)","rgb(255,175,84)","rgb(154,184,183)","rgb(210,166,131)","rgb(61,105,155)","rgb(135,172,34)","rgb(205,169,8)","rgb(208,33,88)","rgb(208,115,0)","rgb(86,118,118)")

为了更改图表中点的颜色......

我试图更改生成的html的菜单栏...特别是颜色参数(设置一个新的RGB颜色数组),然后ctrl + alt + R重现更改...但没有发生任何事情...

有什么想法吗?

由于

1 个答案:

答案 0 :(得分:0)

传入colorKey:

data <- t(iris[,1:4])
varAnnot <- as.matrix(iris[,5])
colnames(varAnnot) <- "Species"
canvasXpress(t(data), 
    varAnnot=varAnnot, 
    graphType='Scatter3D', 
    colorBy='Species', 
    colorKey=colorKey)

然后致电:

"attributes": {
      "title": "JSON API paints my bikeshed!"
      "city": "Paris"
      ...
    },