deepayan / lattice

Trellis Graphics for R
http://lattice.r-forge.r-project.org/
Other
68 stars 15 forks source link

Understanding the basic with levelplot #25

Open jpearson0525 opened 2 years ago

jpearson0525 commented 2 years ago

I'm using levelplot successfully when I have one value per point on the surface. It's the RF strength of a transmitter. It appears the points are marked with a circle and the color matches the value of the signal strength at the point and thus the area around the point. Now I move on to having multiple RF signal strength per point - from different transmitters. I can't figure out how levelplot is responding to this case. Does it take the mean, median, highest or lowest value for the color of the point? What value is used in the computation for the color of the surface?

Second question: Is there a way to have levelplot generate a plot beyond (left, right, up or down) the bounds of the point locations? Like 1" beyond?

Thank you for your assistance. Jim Pearson

deepayan commented 2 years ago

I'm not sure how you are using levelplot(); could you provide some example code? In particular, the default levelplot display doesn't use circles.

For extending the plot, the standard way is to specify xlim and ylim.

m-jahn commented 2 years ago

If I understand the question correctly the question is what happens if values are duplicated in the data, i.e. several Z values correspond to the grid made of the two variables X and Y. Well in that case lattice just overplots duplicated values on existing ones, as this examples shows. No mean or median is calculates by default.

library(lattice)

# data frame with only 1 value per pos
df <- data.frame(
  a = rep(c("A", "B", "C"), 3),
  b = rep(1:3, each = 3),
  c = rnorm(n = 9)
)

levelplot(c ~ factor(b) * factor(a), df)

# add one duplicated value
df2 <- rbind(df, c("C", 3, 0.0))

levelplot(c ~ factor(b) * factor(a), df2)
m-jahn commented 2 years ago

Can probably be closed if opener has no more comments @jpearson0525 ?