Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lineheight < 1 does not reduce size of linebreaks #96

Open
swhalemwo opened this issue Sep 28, 2022 · 0 comments
Open

lineheight < 1 does not reduce size of linebreaks #96

swhalemwo opened this issue Sep 28, 2022 · 0 comments

Comments

@swhalemwo
Copy link

thanks for this great package! While working with it, I noticed that lineheights are not properly scaled when they are smaller than 1.

library(ggplot2)
library(ggtext)
library(gridExtra)

df2 <- data.frame(x=c(1,2), y=c(2,1), 
                  label1 = c("linebreaks\nlinebreaks\nlinebreaks", "linebreaks\nlinebreaks\nlinebreaks"),
                  label2 = c("linebreaks<br>linebreaks<br>linebreaks", "linebreaks<br>linebreaks<br>linebreaks"))


## small linebreaks work in geom_label
p1 <- ggplot(df2, aes(x=x, y=y)) +
    geom_label(aes(label = label1), lineheight = 0.3) +
    xlim(0, 3) + ylim(0,3)
    
## small linebreaks don't work properly in geom_richtext
p2 <- ggplot(df2, aes(x=x, y=y)) +
    geom_richtext(aes(label = label2), lineheight = 0.3) +
    xlim(0, 3) + ylim(0,3)

## larger linebreaks work properly 
p3 <- ggplot(df2, aes(x=x, y=y)) +
    geom_richtext(aes(label = label2), lineheight = 3) +
    xlim(0, 3) + ylim(0,3)

grid.arrange(p1,p2,p3)

Created on 2022-09-28 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant