tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.51k stars 2.03k forks source link

missing `guide.margin`(s) theme parameter #819

Closed baptiste closed 10 years ago

baptiste commented 11 years ago

I believe the theme parameters are not fully covering the margin options for guides. In this SO question, I discovered an extra margin that is being set to a default value and cannot be specified in theme().

r-cheologist commented 11 years ago

Just making sure I get updates ...

jtoloe commented 11 years ago

Seems like this extra margin is added to the guides grob within the guide-box grob. This gives the guides grob layout three width and height elements even if it only contains one grob.

leg$grobs[[1]]$heights
# [1] 0.5lines                                                                     
# [2] sum(1.5mm, 2.63333333333333mm, 1.52926814814815mm, 6.11707259259259mm, 1.5mm)
# [3] 0.5lines
leg$grobs[[1]]$layout
# t l b r z clip   name
# 1 2 2 2 2 1  off guides

This seems wrong to me. Would a solution be to not add those two 0.5lines but add them to the default legend.margin instead to not mess with the current defaults?

Ah, no wait that wouldn't work since the effect is different, a sort of inner and outer margin.

baptiste commented 11 years ago

what's wrong with adding that guide.margin parameter to theme_grey() etc. with default value 0.5 line? It sounds like a more minimal change to make (provided one understands the themes system, which I don't).

b.

On 13 June 2013 06:30, Johan Tolö notifications@github.com wrote:

Seems like this extra margin is added to the guides grob within the guide-box grob. This gives the guides grob layout three width and height elements even if it only contains one grob.

leg$grobs[[1]]$heights# [1] 0.5lines # [2] sum(1.5mm, 2.63333333333333mm, 1.52926814814815mm, 6.11707259259259mm, 1.5mm)# [3] 0.5linesleg$grobs[[1]]$layout# t l b r z clip name# 1 2 2 2 2 1 off guides

This seems wrong to me. Would a solution be to not add those two 0.5linesbut add them to the default legend.margin instead to not mess with the current defaults?

— Reply to this email directly or view it on GitHubhttps://github.com/hadley/ggplot2/issues/819#issuecomment-19381219 .

hadley commented 10 years ago

This sounds like a great feature/horrible bug, but unfortunately we don't currently have the development bandwidth to support it/fix it. If you'd like to submit a pull request that implements this feature/fixes this bug, please follow the instructions in the development vignette.