简体   繁体   中英

Divided the color in scatterplot3d

Need your advice to color scatterplot3d according to Year category. I have the dataset as follows:

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

I created syntax as follows

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),
              )

and the result,

I couldn't divided the color according the Year

Could you please give me help to divided the color according the year from dataset?

You can just pass data2d$Year to 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),
              )

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM