R ggplot2元素“文本(面=”斜体“) 问题
当我使用R ggplot2元素“文本(面=”斜体“) 问题,r,ggplot2,R,Ggplot2,当我使用element\u text(face=“italic”)时,绘图中的文本不是斜体 Plot 2在我的Macbook上使用GGPlot 2_2.2.1.9000和R 3.4.2可以正常工作 Plot 2在使用ggplot2_2.2.1和R 3.4.0的Linux服务器上无法运行 解决方案 我应该采取什么步骤为R正确设置字体 例子 定义绘图: p <- ggplot(data.frame(x = 1, y = 1), aes(x, y)) + geom_point() + l
element\u text(face=“italic”)
时,绘图中的文本不是斜体
Plot 2在我的Macbook上使用GGPlot 2_2.2.1.9000和R 3.4.2可以正常工作
Plot 2在使用ggplot2_2.2.1和R 3.4.0的Linux服务器上无法运行
解决方案
我应该采取什么步骤为R正确设置字体
例子
定义绘图:
p <- ggplot(data.frame(x = 1, y = 1), aes(x, y)) +
geom_point() +
labs(title = "My Title")
地块2(良好)
问题随着family=“sans”
而消失:
在Ubuntu 16.04上,这足以让斜体字体正常工作:
# Update the list of packages
sudo apt-get update
# Arial
sudo apt-get install ttf-mscorefonts-installer
# Helvetica
sudo apt-get install texlive-fonts-recommended
# Refresh the font cache
sudo fc-cache -f -v
# Restart the R Shiny server
sudo systemctl restart shiny-server
R绘图到设备。您需要查看设备使用的字体。在Mac上查看屏幕设备的帮助页面:
?quartz
,而在Linux上查看?x11
。每个页面都有关于选择字体的信息(或指向其他帮助页面的链接)。
p + theme(
plot.title = element_text(
color = "red", face = "italic", family = "sans"
)
)
# Update the list of packages
sudo apt-get update
# Arial
sudo apt-get install ttf-mscorefonts-installer
# Helvetica
sudo apt-get install texlive-fonts-recommended
# Refresh the font cache
sudo fc-cache -f -v
# Restart the R Shiny server
sudo systemctl restart shiny-server