Discussion:
ggplot geom_hex binning information
Marck Vaisman
2011-04-13 20:46:43 UTC
Permalink
Hello everyone,

I've been using the hexbin package and the plot(hexobject) call to do some
hexbin plots but I can't customize it enough to suit my needs so I want to
use ggplot. When you create a hexbin with the hexbin() function you get an
object where you can see the coordinates of each bin and its associated
count.

Is there any way to see within a ggplot object created with geom_hex() how
the data was binned and counted - i.e. what are the attributes of each
hexagon created, and its' respective count? Is there a way to I see the code
of the hex binning piece?

I want to do some customization with the breaks/labels in my hexagon fill
gradients, but I want to know what the summary of the counts and make it
dynamic for several charts. My data has a very high number of bins with a
count of 1, and then it's all over the place. I want to use a gradient fill
and make the bins with count = 1 a light color and then successively darker
as the counts increase, but I'd like to know the distribution of the counts
to do that.

Thanks,
Marck
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
wahalulu
2011-04-13 21:42:22 UTC
Permalink
(please forgive if this comes through twice... I emailed it some time ago
but it hasn't shown up on the topic list.)

Hello everyone,

I've been using the hexbin package and the plot(hexobject) call to do some
hexbin plots but I can't customize it enough to suit my needs so I want to
use ggplot. When you create a hexbin with the hexbin() function you get an
object where you can see the coordinates of each bin and its associated
count.

Is there any way to see within a ggplot object created with geom_hex() how
the data was binned and counted - i.e. what are the attributes of each
hexagon created, and its' respective count? Is there a way to I see the code
of the hex binning piece?

I want to do some customization with the breaks/labels in my hexagon fill
gradients, but I want to know what the summary of the counts and make it
dynamic for several charts. My data has a very high number of bins with a
count of 1, and then it's all over the place. I want to use a gradient fill
and make the bins with count = 1 a light color and then successively darker
as the counts increase, but I'd like to know the distribution of the counts
to do that.

Thanks,
Marck
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Hadley Wickham
2011-04-14 12:08:18 UTC
Permalink
No, it's not currently possible. the best way is to bin outside
ggplot2 and then plot. I'm working on exposing the internal pieces
better.


Hadley
(please forgive if this comes through twice... I emailed it some time ago but it hasn't shown up on the topic list.)
Hello everyone,
I've been using the hexbin package and the
plot(hexobject) call to do some hexbin plots but I can't customize it
enough to suit my needs so I want to use ggplot. When you create a
hexbin with the hexbin() function you get an object where you can see
the coordinates of each bin and its associated count.
Is there any way to see within a ggplot object created with
geom_hex() how the data was binned and counted - i.e. what are the
attributes of each hexagon created, and its' respective count? Is there a
way to I see the code of the hex binning piece?
I want to do some customization with the breaks/labels in my hexagon
fill gradients, but I want to know what the summary of the counts and
make it dynamic for several charts. My data has a very high number of
bins with a count of 1, and then it's all over the place. I want to use a
gradient fill and make the bins with count = 1 a light color and then
successively darker as the counts increase, but I'd like to know the
distribution of the counts to do that.
Thanks,
Marck
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
More options: http://groups.google.com/group/ggplot2
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
Hadley Wickham
2011-04-14 12:34:25 UTC
Permalink
You need to use geom_hex() with stat = "identity". And you also need
the data in the format that geom_hex uses - which is not trivial.
Hopefully this summer I'll replace the internal code with
https://github.com/hadley/densityvis/blob/master/R/bin-hex.r (which
also provides a pretty fast pure R implementation of hex binning)

Hadley
Thanks Hadley.
If I bin outside and then plot with geom_hex, will that call bin my binned data? I actualy tried your suggestion before asking the question and it seems it does. If I use geom_point I get the same output as plot(hexbin()) but using dots. How can I turn the geom_point points into hex's without rebinning?
Thanks,
Marck
-----Original Message-----
Date: Thu, 14 Apr 2011 07:08:18
Subject: Re: ggplot geom_hex binning information
No, it's not currently possible. the best way is to bin outside
ggplot2 and then plot. I'm working on exposing the internal pieces
better.
Hadley
(please forgive if this comes through twice... I emailed it some time ago but it hasn't shown up on the topic list.)
Hello everyone,
I've been using the hexbin package and the
plot(hexobject) call to do some hexbin plots but I can't customize it
enough to suit my needs so I want to use ggplot. When you create a
hexbin with the hexbin() function you get an object where you can see
the coordinates of each bin and its associated count.
Is there any way to see within a ggplot object created with
geom_hex() how the data was binned and counted - i.e. what are the
attributes of each hexagon created, and its' respective count? Is there a
 way to I see the code of the hex binning piece?
I want to do some customization with the breaks/labels in my hexagon
 fill gradients, but I want to know what the summary of the counts and
make it dynamic for several charts. My data has a very high number of
bins with a count of 1, and then it's all over the place. I want to use a
 gradient fill and make the bins with count = 1 a light color and then
successively darker as the counts increase, but I'd like to know the
distribution of the counts to do that.
Thanks,
Marck
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
More options: http://groups.google.com/group/ggplot2
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
More options: http://groups.google.com/group/ggplot2
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Loading...