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'm trying to profit from ggtext's more generous behavior of vectorized input to element_text() to plot multiple subtitles on the same line (see f.e. here).
I'm wondering about the behavior of hjust = c(0, 1) in element_markdown() however, that deviates from the ggplot2-native element_text() function:
library(ggplot2)
gg<- ggplot(data=mtcars, aes(x=disp, y=mpg)) +
geom_line() +
labs(subtitle= c("left-aligned subtitle", "right-aligned subtitle"))
# ggplot2 versiongg+
theme(
plot.subtitle= element_text(hjust= c(0, 1))
)
#> Warning: Vectorized input to `element_text()` is not officially supported.#> ℹ Results may be unexpected or may change in future versions of ggplot2.
# ggtext# how I was expecting it to workgg+
theme(
plot.subtitle=ggtext::element_markdown(hjust= c(0, 1))
)
# how it actually workedgg+
theme(
plot.subtitle=ggtext::element_markdown(hjust= c(1, 5))
)
The text was updated successfully, but these errors were encountered:
balthasars
changed the title
`hjust = c(0, 1)
Behavior of hjust = c(0, 1) of ggtext::element_markdown() is different from that of ggplot2::element_text()May 14, 2024
balthasars
changed the title
Behavior of hjust = c(0, 1) of ggtext::element_markdown() is different from that of ggplot2::element_text()
Behavior of hjust = c(0, 1) in ggtext::element_markdown() is different from that of ggplot2::element_text()May 14, 2024
I'd be happy do a PR and improve the documentation @bwiernik if hjust = c(1, 5) is how it should work.
Also had a quick look at the source code (also for richtext_grob()) from gridtext but it wasn't immediately clear to me what the arguments should be to get the vectorized input working as demonstrated above,
I'm trying to profit from
ggtext
's more generous behavior of vectorized input toelement_text()
to plot multiple subtitles on the same line (see f.e. here).I'm wondering about the behavior of
hjust = c(0, 1)
inelement_markdown()
however, that deviates from the ggplot2-nativeelement_text()
function:Created on 2024-05-14 with reprex v2.1.0
Thanks in advance for any pointers! :)
The text was updated successfully, but these errors were encountered: