【问题标题】:Divided the color in scatterplot3d在 scatterplot3d 中划分颜色
【发布时间】:2020-12-10 18:59:09
【问题描述】:

根据Year 类别需要您的建议来为 scatterplot3d 着色。我的数据集如下:

data2d

No d_Mart     d_Train   Price  Year
1  371.20750  945.8907  304    2013
2  1396.94337 2347.5052 446    2015
3  393.82319  1092.1655 802    2016
4  1183.18903 1455.1527 445    2017
5  374.89814  1027.8457 707    2018
6  260.44635  871.1573  310    2019
7  366.81782  1258.1917 534    2014

我创建的语法如下

scatterplot3d(data2d[,1:3], pch = 20, type="h",
              main="Distance to market vs distance to train station",
              xlab = "Distance to market",
              ylab = "Distance to train station",
              zlab = "Price (IDR)",
              angle = 45,
              color = 'red',
              legend = levels(data2d$Price),
              )

结果,

我无法按年份划分颜色

你能帮我从数据集中根据年份划分颜色吗?

【问题讨论】:

    标签: r scatter3d


    【解决方案1】:

    您可以将data2d$Year 传递给color

    scatterplot3d(data2d[,1:3], pch = 20, type="h",
                  main="Distance to market vs distance to train station",
                  xlab = "Distance to market",
                  ylab = "Distance to train station",
                  zlab = "Price (IDR)",
                  angle = 45,
                  color = data2d$Year,
                  legend = levels(data2d$Price),
                  )
    

    【讨论】:

      猜你喜欢
      • 2022-01-11
      • 2021-03-07
      • 2010-12-11
      • 2012-08-22
      • 2019-03-02
      • 2018-04-25
      • 2023-01-25
      • 2011-12-02
      • 2018-04-02
      相关资源
      最近更新 更多