0
votes

I have a plot like this, which I would like to change:

enter image description here

I would like to make this a density plot, like the hexbin below:

http://www.exegetic.biz/blog/wp-content/uploads/2013/05/hexbin-mass-height.png

where each of the colors in the first figure can have its own unique color gradient I am not happy with R's hexbin, as it does not allow logarithmic scales as I need in the first figure. Another benefit of this binning is that I can make an encapsulated postscript output, as an EPS of the first file is large & unopenable.

I've seen density plots in pm3d, but doing this with more than one set of data doesn't make sense (8 different color gradients in the right side would look bad)

How can I do hexbin-like plots in gnuplot?

1
You cannot do this automatically with gnuplot, there is only a pending feature request: sourceforge.net/p/gnuplot/feature-requests/329Christoph
I am not happy with R's hexbin, as it does not allow logarithmic scales: it does. use scale_x_log10 and scale_y_log10.Henk

1 Answers

1
votes

Per @Henk:

library(gridExtra)
library(ggplot2)

grid.arrange(
  ggplot(diamonds, aes(carat, price)) + geom_hex() + scale_y_continuous(name="identity", trans="identity"),
  ggplot(diamonds, aes(carat, price)) + geom_hex() + scale_y_continuous(name="sqrt", trans="sqrt"),
  ggplot(diamonds, aes(carat, price)) + geom_hex() + scale_y_continuous(name="log10", trans="log10"),
  ggplot(diamonds, aes(carat, price)) + geom_hex() + scale_y_continuous(name="log2", trans="log2"),
  ncol=1)

enter image description here