简体   繁体   English

如何根据数据框列设置 R plotrix::polar.plot 中符号的大小和/或颜色?

[英]How I can set the size and/or color of symbols in a R plotrix::polar.plot on the basis of a data frame column?

I have a data frame "df" with three columns: distance, azimuth, intensity.我有一个包含三列的数据框“df”:距离、方位角、强度。 Through plotrix:polar.plot I got a plot using the following code通过plotrix:polar.plot我使用以下代码得到了 plot

polar.plot(df$distance, df$azimuth, radial.lim=c(0,450),start=90,rp.type = "s", clockwise=TRUE, point.col=4, cex = 1.2)

Is there a way to have the size (or color) of symbols changing with the "intensity" column value?有没有办法让符号的大小(或颜色)随着“强度”列值的变化而变化?

since I didn't find any "direct" solution I have divided the dataframe in several dataframes using subset() and after I plotted every dataframe with different "cex"/"point.col" setting to "TRUE" the "add" parameter.因为我没有找到任何“直接”解决方案,所以我使用子集()将 dataframe 划分为几个数据帧,并且在我用不同的“cex”/“point.col”设置为“TRUE”绘制每个 dataframe 之后,将“add”参数.

df3 <- subset(outPutDeg, intensity <= 3)
df5 <- subset(outPutDeg, intensity > 3 & intensity <= 5)
df7 <- subset(outPutDeg, intensity > 5 & intensity <= 7)
df9 <- subset(outPutDeg, intensity > 7 & intensity <= 9)
df11 <- subset(outPutDeg, intensity > 9)

polar.plot(df3$distance, df3$azimuth, radial.lim=c(0,450),start=90,rp.type = "s", clockwise=TRUE, point.col=5, cex = 0.6)
polar.plot(df5$distance, df5$azimuth, radial.lim=c(0,450),start=90,rp.type = "s", clockwise=TRUE, point.col=4, cex = 0.6, add = T)
polar.plot(df7$distance, df7$azimuth, radial.lim=c(0,450),start=90,rp.type = "s", clockwise=TRUE, point.col=3, cex = 0.6, add = T)
polar.plot(df9$distance, df9$azimuth, radial.lim=c(0,450),start=90,rp.type = "s", clockwise=TRUE, point.col=2, cex = 0.6, add = T)
polar.plot(df11$distance, df11$azimuth, radial.lim=c(0,450),start=90,rp.type = "s", clockwise=TRUE, point.col=1, cex = 0.6, add = T)

crude and effective粗略而有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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