You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a feature request – support for mapping the width and height values, not just setting them. This is needed when one uses geom_tile() instead of geom_rect() to draw the boxes that the geom_fit_text() text is supposed to be placed into. And geom_tile() is needed when one of the axis is discrete, i.e. a factor. Here’s a small reproducible example.
This looks fine. But using as.numeric() on the cat factor inside aes() is an ugly hack, which causes problems later. A better solution is to use geom_tile():
The boxes are laid out the same, but the width and height aesthetics are not recognised by geom_fit_text(). Of course, I can set the width and height, but then it would be the same for both (all) boxes, so there would either be overflowing text or too much space inside the boxes.
Now for the reason I need to use geom_tile() instead of geom_rect(). The as.numeric() hack doesn’t work when one uses faceting with free scales and not all levels of the factor are present in all panels. Here’s a simple example:
p_rect+ facet_wrap(~cat, scales="free_y")
Note the wrong vertical placement of the box in panel R2 / the wrong y-axis labelling.
When one uses geom_tile() instead, there’s no problem, since the internals of ggplot2 handle the vertical placement and takes care of any missing levels:
# Correct placement and y axisp_tile+ facet_wrap(~cat, scales="free_y")
But then geom_fit_text() doesn’t work properly, as it doesn’t recognise the width and height aesthestics.
The text was updated successfully, but these errors were encountered:
Thank you for this extremely useful package!
I have a feature request – support for mapping the
width
andheight
values, not just setting them. This is needed when one usesgeom_tile()
instead ofgeom_rect()
to draw the boxes that thegeom_fit_text()
text is supposed to be placed into. Andgeom_tile()
is needed when one of the axis is discrete, i.e. a factor. Here’s a small reproducible example.This looks fine. But using
as.numeric()
on thecat
factor insideaes()
is an ugly hack, which causes problems later. A better solution is to usegeom_tile()
:The boxes are laid out the same, but the
width
andheight
aesthetics are not recognised bygeom_fit_text()
. Of course, I can set thewidth
andheight
, but then it would be the same for both (all) boxes, so there would either be overflowing text or too much space inside the boxes.Now for the reason I need to use
geom_tile()
instead ofgeom_rect()
. Theas.numeric()
hack doesn’t work when one uses faceting with free scales and not all levels of the factor are present in all panels. Here’s a simple example:Note the wrong vertical placement of the box in panel R2 / the wrong y-axis labelling.
When one uses
geom_tile()
instead, there’s no problem, since the internals of ggplot2 handle the vertical placement and takes care of any missing levels:But then
geom_fit_text()
doesn’t work properly, as it doesn’t recognise thewidth
andheight
aesthestics.The text was updated successfully, but these errors were encountered: