R xy 散点图标记颜色
尝试绘制 xy 散点图,其中 z 值由 xy 点的颜色表示。
数据:
1.1, 32.27, 19.4
1.2, 21.34, 18
1.4, 47.45, 19.4
R 代码:
inp <- scan("beps.txt",list(x=0,y=0,z=0))
plot(inp$x, inp$y,pch=".")
创建一个很棒的散点图,但我希望这些点按 Z 值着色。
Trying to do an xy scatter plot with the z value being denoted by the color of the xy point.
Data:
1.1, 32.27, 19.4
1.2, 21.34, 18
1.4, 47.45, 19.4
R code:
inp <- scan("beps.txt",list(x=0,y=0,z=0))
plot(inp$x, inp$y,pch=".")
Creates a great scatter plot, but I would like the points to be colored by the Z value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一些使用 ggplot2 的可重现示例。如果我理解正确的话我应该做你想做的事。
一般来说,我强烈推荐 ggplot2 来完成类似的事情。这确实值得我们多学习一点。我仍处于这个过程的中间,意识到在 ggplot2 上投入一些时间是值得的。如果您不知道该软件包和文档,请务必检查一下。该文档易于理解且功能强大!
Here is some reproducible example that uses ggplot2. If I understood you correctly I should do what you want.
In general I strongly recommend ggplot2 for stuff like that. It's really worth learning a little more about. I am still in the middle of the process and realize how much it pays to put some time into ggplot2. If you do not know the package and the documentation, make sure you check it. The documentation is easy to understand and powerful !
因此,设置颜色参数:
但请注意,颜色是整数值。
So set the color argument:
Note though that colors are integer-valued.
与德克的答案类似,使用:
当然,您可以使用其他配色方案。参见?heat.colors
Similar to Dirk's answer, use:
You can, of course, use other color schemes. see ?heat.colors