【问题标题】:How to define marker color based on category string value for a 3d scatter plot如何根据 3d 散点图的类别字符串值定义标记颜色
【发布时间】:2022-01-03 21:34:56
【问题描述】:

我将在 R 中绘制一个 3D 散点图,我想根据字符串或数字类别为图中的点着色。

类别是

"cancer control control control control cancer  cancer  control cancer  control........" 

1 0 0 0 0 1 1 0 1 0...... 

代码如下:

library("plot3D")
scatter3D(pcr$PC1, pcr$PC2, pcr$PC3,color=category)

输出是 here

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: r plot scatter3d


【解决方案1】:

您应该上传一个可重现的示例,但我认为您的 category 变量是连续的。你应该变成一个因素。

yourdata$category = as.factor(yourdata$category)

然后您尝试再次绘制图形。 也许它会帮助你。

【讨论】:

  • 非常感谢您的回复。没有我的颜色数据是因素。
猜你喜欢
  • 2021-10-13
  • 2021-07-13
  • 1970-01-01
  • 2021-10-05
  • 1970-01-01
  • 2019-03-28
  • 2015-06-06
  • 1970-01-01
  • 2019-12-22
相关资源
最近更新 更多