1
votes

About the command 'scatterPlot' from package 'openair' of R, I used the following command:

data(mydata)

scatterPlot(mydata, x = "nox", y = "no2", method = "hexbin",
            colorcut = seq(0, 1, length = 7), cols =  "default", trans=log, inv=exp)

and I got this graphic:

Please Click Here To See The Graphic

I need to know if it is possible to have two Scatterplots on the same graph, one with the method "hexbin" and other with the method "scatter"?

Or, more specifically, it is possible to plot points of another variable over a scatterplot hexbin? I tried to do this for a while, but I did not get hit.

I appreciate any help.

1
Perhaps you can use ggplot2. You could use both geom_hex and geom_point. For example, using the diamonds data set, you could do something like the following d <- ggplot(diamonds, aes(carat, price)) and d + geom_hex() + geom_point(aes(carat, price), size = .15, colour = 'magenta', alpha=.15)steveb
I appreciate your answer, @steveb. But you can tell me if there is, somehow, some way to make this using scatterPlot (by openair), or even using hexbinplot (by hexbin)?Dani Depi
I don't really know. I had a quick look at the openair manual but didn't see anything that would help. If nobody answers your question on SO, you could contact them at openair-project.org/Contact.aspxsteveb
I have already send a email to professor Carslaw, but I asked here too because we never know who can knows too :) Thank you for your attention, @steveb !Dani Depi
@steveb , I'm here to say that professor Carslaw answered my email with the following solution that worked for me: library(latticeExtra); plt <- scatterPlot(mydata, method = "hexbin", col = "jet"); b <- scatterPlot(head(mydata, 200), col = "black", pch = 16, cex = 0.5); plt$plot + as.layer(b$plot)Dani Depi

1 Answers

3
votes

I'm here to say that professor Carslaw (the author of the 'openair' package, which have the 'scatterPlot' command) answered my email with the following solution that worked for me:

library(latticeExtra)
plt <- scatterPlot(mydata, method = "hexbin", col = "jet")
b <- scatterPlot(head(mydata, 200), col = "black", pch = 16, cex = 0.5)
plt$plot + as.layer(b$plot)