2011-09-06 98 views
7

關於如何校準cex字體大小單位的任何想法?如何指定圖中的字體大小(對於PDF輸出)?

具體來說,我想使用默認系列「Helvetica」並指定字體大小以對應.doc字體大小。例如,對於主標題使用字體大小12,對於軸標題使用字體大小10。

我會很感激您的意見和建議。謝謝!

回答

2

你的第一個問題需要一些繁重的工作。這裏有一個很好的說明: http://www.jameskeirstead.ca/typography/changing-the-fonts-in-r-plots/我不知道「更簡單的方法」。但我很想看到一個。

對於第二個問題:請參閱?par,特別是關於cex的部分。

cex 
cex.axis 
cex.lab 
cex.main 

此外,還可以惹的?pdfpointsize設置調整相對大小。

+0

不幸的是,在該鏈路的末端位表示,它並不適用於PDF格式的設備。 –

3

您可以在繪圖的基礎上設置默認字體。

par(family = 'Helvetica') 
plot(rnorm(10), main = 'Something In Helvetica') 

還有一個par('font'),你可以用它來設置字體是否爲粗體,斜體等,對於尺寸,除了布蘭登,允許一個設置字體大小提到的CEX組參數一個相對的術語,還有cin,cra,我相信更多的是允許用英寸或像素來設置尺寸。不幸的是,您無法指定標準字體大小爲10或12.

請檢查par()的幫助並仔細閱讀。

+0

你是先生,是天才。 – by0

0

也許嘗試使用pointsize = 12,在您的quartz()https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/quartz.html

quartz(pointsize = 12) 

出於某種原因,我的家人= 「黑體」 不工作,當放置在quartz()

兩個變化 - 變化字體字號工作順序:

quartz(pointsize = 12) # define point size 
par(mar=c(3,3,1,1), family = "Helvetica") # define family 
plot(...) 

因此,pdf()情節出口和quartz()輸出,因爲它們沒有在同一運行時間 - 我使用pdf()來輸出我的圖,但石英()只是爲了將圖複製到MS Word文檔中

library(extrafont)  # library needed to have your fonts 
loadfonts() ## for pdf() 

# pdf plot export - now doesn't run, because now I want just check changes in my quartz() plotting 
# pdf("my_plot_in_pdf.pdf", height = 4, width = 4, family = "Helvetica") 

quartz(height = 4, width = 4, pointsize = 12) # check my changes in plot, if I want to export my plot, I just set #quartx(...) 
    par(mar=c(4,4,1,1), family = "Helvetica") 
    plot(cars, main = "Helvetica, 12", ylab = "y label", xlab = "x label", cex = 1) 
    dev.off() 

enter image description here

或更改我的家人和點大小:

quartz(height = 4, width = 4, pointsize = 20) 
par(mar=c(4,4,1,1), family = "Times New Roman") 
plot(cars, main = "Times New Roman, 20", ylab = "y label", xlab = "x label", cex = 1) 
dev.off() 

enter image description here

相關問題