如何在R中以图形方式使因子级别的“ scatter3d”尊重顺序

时间:2018-11-14 14:38:30

标签: r r-plotly

考虑以下示例,其中明确设置了级别顺序:

library(plotly)
iris$sp <- factor(iris$Species, c("versicolor", "setosa", "virginica"))

二维散点图遵循因子水平的顺序:

plot_ly(data = iris,
        x = ~sp, 
        y = ~Sepal.Width,
        type = "scatter",
        mode = "markers",
        marker = list(opacity = 0.6, size = 4)) 

csv.DictWriter()

3D散点图没有:

plot_ly(data = iris,
        x = ~sp, 
        y = ~Sepal.Length,
        z = ~Sepal.Width,
        type = "scatter3d",
        mode = "markers",
        marker = list(opacity = 0.6, size = 4)) 

enter image description here

问题:如何使plotly“ scatter3d”遵守R中因子水平的顺序?

现在看来,这些级别在3D图中已按字符串排序。 是虫子吗?还是故意制造的?

0 个答案:

没有答案