简体   繁体   中英

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. Through plotrix:polar.plot I got a plot using the following code

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.

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

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