-
Notifications
You must be signed in to change notification settings - Fork 38
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
showtext appears to be double spacing labels/titles #26
Comments
Same issue observed |
I'll take a look some time later this week. |
I was trying to investigate this issue today, but I couldn't reproduce it. The spacing seems correct for the minimal example below. Can someone give me a (runnable) example that has double spacing? library(showtext)
library(ggplot2)
showtext_auto()
dat = data.frame(x = c("AAA\nAAA", "BBB\nBBB", "CCC\nCCC"), y = 1:3)
x11()
ggplot(dat, aes(x = x, y = y)) +
geom_bar(stat = "identity") +
ggtitle("First Line\nsecond line") +
theme_grey(base_family = "sans") |
Hi-
Thanks for taking a look. It shows up correctly (no extra spacing) in the
preview window, but once I ggsave it, the spacing appears. I added a
googlefont to your code.
library(showtext)
library(ggplot2)
font_add_google("Merriweather", "Merri", regular.wt = 400)
showtext_auto()
dat = data.frame(x = c("AAA\nAAA", "BBB\nBBB", "CCC\nCCC"), y = 1:3)
x11()
ggplot(dat, aes(x = x, y = y)) +
geom_bar(stat = "identity") +
ggtitle("First Line\nsecond line") +
theme_grey(base_family = "Merri")
ggsave(file="shotwtext_example.png", type="cairo-png", width=5, height=5)
…On Fri, Dec 14, 2018 at 11:42 AM Yixuan Qiu ***@***.***> wrote:
I was trying to investigate this issue today, but I couldn't reproduce it.
The spacing seems correct for the minimal example below. Can someone give
me a (runnable) example that has double spacing?
library(showtext)
library(ggplot2)
showtext_auto()
dat = data.frame(x = c("AAA\nAAA", "BBB\nBBB", "CCC\nCCC"), y = 1:3)
x11()
ggplot(dat, aes(x = x, y = y)) +
geom_bar(stat = "identity") +
ggtitle("First Line\nsecond line") +
theme_grey(base_family = "sans")
[image: image]
<https://user-images.githubusercontent.com/216398/50015519-cdee7680-ff94-11e8-8b9b-fc31ac2e0ab2.png>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#26 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AmJj0ycnXJjHwUlPjSoioV4pcrzEy1fwks5u49TcgaJpZM4X1rqq>
.
|
The issue is also observed when using showtext within a Rmarkdown document. |
OK, now I know the problem. The fact is not that the spacing is doubled, but that the font sizes are made smaller. showtext_opts(dpi = 300) The same reason applies to Rmarkdown. You need to make sure the |
Would it be possible to find a way in Rmarkdown for |
@larmarange I find that adding the following option to the document header automatically solves the problem. Can you confirm this? ---
output:
html_document:
fig_retina: 1
--- |
Love the ease of this package. But when I use the "\n" function to separate labels to a second line I am getting double spacing which I can't correct outside of photoshop. Here's an example with labels and titles showing the double spacing.
fpol %>% filter(pid7!="NA") %>% ggplot(., aes(x=q18_1, y=factor(pid7), fill=..x..)) +
geom_density_ridges_gradient(rel_min_height=.02) +
scale_fill_gradient2(low="dodgerblue3", high="firebrick3", mid="white", midpoint=50) +
theme_minimal() +
labs(x="", y="", title="Only Strong Republicans Are Happy\nwith Trump Admin's Management", caption="Source: February 2018") +
theme(legend.position = "none") +
scale_x_continuous(breaks=c(0,25,50,75,100), labels=c("Extremely\nUnhappy","25","Neither\nHappy\nNor\nUnhappy", "75", "Extremely\nHappy")) +
theme(text=element_text(family="JSans", size=20))
The text was updated successfully, but these errors were encountered: