如何从 ggplot2 包中仅绘制 geom_point 中的一系列值?
大家好, 我有以下熔融数据:
X variable value
1 StationA SAR11.cluster 0.001309292
2 StationB SAR11.cluster 0.002712237
3 StationC SAR11.cluster 0.002362708
4 StationD SAR11.cluster 0.002516751
5 StationE SAR11.cluster 0.004301075
6 StationF SAR11.cluster 0.0
.
.
.
etc.
etc.
我使用以下代码绘制了数据的气泡图:
ggplot(foomelt, aes(x=foomelt$Station, y=variable, angle=45, size=(value))) +
+geom_point() + opts(theme_bw(), axis.text.x = theme_text(size=10, angle = 70))
+ scale_area()
一切都很好,只是我想忽略 0(零)值并且仅用于缩放所有这些值之间的点值大于零和最大值。 我不想从数据中删除零值行,因为为了证明一点,我希望包含所有站和变量,并将零值的那些留空。
我设法使用它来忽略零值,但缩放不起作用:
ggplot(foomelt, aes(x=foomelt$Station, y=variable, angle=45, size=(value>0))) +
+ geom_point() + opts(theme_bw(), axis.text.x = theme_text(size=10, angle = 70))
+ scale_area("Ratio") + scale_size_identity()
任何帮助将不胜感激。
Hello All,
I have the following molten data:
X variable value
1 StationA SAR11.cluster 0.001309292
2 StationB SAR11.cluster 0.002712237
3 StationC SAR11.cluster 0.002362708
4 StationD SAR11.cluster 0.002516751
5 StationE SAR11.cluster 0.004301075
6 StationF SAR11.cluster 0.0
.
.
.
etc.
etc.
I used the following code to chart a bubblechart of the data:
ggplot(foomelt, aes(x=foomelt$Station, y=variable, angle=45, size=(value))) +
+geom_point() + opts(theme_bw(), axis.text.x = theme_text(size=10, angle = 70))
+ scale_area()
All is well except that I want to ignore the 0 (zero) values and only use for the scaling of the dots values between all those that are grater than zeroes and the max value.
I don't want to delete the zero values rows from the data because in order to prove a point I want all the stations and variables to be included and to have those with the zero value left blank.
I managed to use this to ignore the zero values but scaling does not work:
ggplot(foomelt, aes(x=foomelt$Station, y=variable, angle=45, size=(value>0))) +
+ geom_point() + opts(theme_bw(), axis.text.x = theme_text(size=10, angle = 70))
+ scale_area("Ratio") + scale_size_identity()
any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这是否是您正在寻找的,但在绘制点时忽略零值的一种方法是将 geom_point() 语句修改为该
行仅传递要绘制的数据框中的非零值。
i am not sure if this is what you are looking for, but one approach to ignore the zero values while plotting the points is to modify your geom_point() statement to
this line passes only the non zero values in the data frame to be plotted.
只是为了展示我如何使用 Ramnath(谢谢!)的建议(以便帮助像我这样的新手):
Just to show how I used Ramnath's (thanks!) suggestions (so to help novices like myself):