Nói rằng tôi có một tập dữ liệu như thế này:Sử dụng một phông chữ từ extrafont trong grid.draw
dat <- data.frame
text = c(
"It made me feel very positive to brand X",
"It was clear and easy to understand",
"I didn't like it al all"),
value=runif(3)
)
tôi có thể vẽ nó trong ggplot sử dụng có thể các TradeGothic LT CondEighteen phông chữ từ extrafonts
gói:
library(ggplot2)
p <- ggplot(dat, aes(text, value)) +
geom_bar(stat="identity") +
coord_flip() +
labs(title=" Do you agree with the following statements?")+
theme_bw(16)+
theme(text=element_text(family="TradeGothic LT CondEighteen"))
ggsave('plot.pdf', plot = plot, path = "/Users/jacobdeecurtis/Desktop")
Nhưng khi tôi sử dụng ggplot_gtable
trên cốt truyện:
gt <- ggplot_gtable(ggplot_build(plot))
gt$layout[which(gt$layout$name == "title"), c("l", "r")] <- c(1, max(gt$layout$r))
grid::grid.draw(plot)
ggsave('plot.pdf', plot = plot, path = "/Users/jacobdeecurtis/Desktop")
Tôi gặp lỗi khi chạy hàm grid.draw. Lỗi này là:
Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
polygon edge not found
In addition: Warning messages:
1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
no font could be found for family "TradeGothic LT CondEighteen"...
Tôi không nhận được báo lỗi khi tôi không sử dụng TradeGothic LT CondEighteen phông chữ .
Cảm ơn sự giúp đỡ của bạn!
Hãy thử ' "TradeGothic LT CondEighteen"' – hrbrmstr
Thú vị. Đó không phải là những gì tôi đã cố gắng? Nó khác biệt như thế nào? –
DID bạn làm 'extrafont :: loadfonts()'? – hrbrmstr