Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

r - Modifying fonts in ggplot2

I am looking for a way to modify font types in ggplot. At the moment I would be happy enough to simply change fonts to the 'courier' font family, but ultimately my goal is to call a custom font template--any input on this latter point would be very much appreciated.

I've done a bit of homework, looking at the following posts and articles:

It may be because I am still a hopeless amateur with ggplot2, but I haven't even been able to switch chart fonts to courier. Any help? I've included the data for the chart in question, below, along with the code, so hopefully this is all easy enough to follow.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think your answer is fine but you can do it more simply:

install.packages("extrafont");library(extrafont)
font_import("Trebuchet MS")
library(ggplot2)
qplot(1:10)+theme(text=element_text(family="Trebuchet MS"))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...