简体   繁体   中英

How to plot colored circles knowing X/Y coordinates, radius and a continuous 3rd parameter in R

In a telecommunication project I have a data basis of a list of antennas with their XY coordinates, emission radius and frequencies. I would like to represent with circles the covered area of each antennas, with a specific color depending on the frequency. Ive been looking for libraries, but I'm very new to R and programmation in general, and I don't find any easy and simple ones. What would you recommend ? Thank you for any help

You can do it with ggplot2 and ggforce package, like this:

  # First generate a sample data
  data <- data.frame(x=rnorm(50),y=rnorm(50),radius = rnorm(50,sd=0.1),freq = factor(1:5,levels=1:5))

  # Load the package
  library(ggplot2)
  library(ggforce)
  # Plot
  ggplot(data=data,aes(x0=x,y0=y,col=freq,r=radius)) + geom_circle() +
    coord_fixed()

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