2014-06-06 25 views
0

在下面的圖中,我試圖讓Arial字體中的所有文本都以軸爲軸(x和y軸中的編號均爲Times New Roman,而legend和mtext爲Arial請任何人都可以建議我怎麼能解決這個問題如何更改r圖中的字體類型

ace_Obs= c(1.80,0.99,4.82,5.03,2.04,1.96,5.89,7.73,5.53,2.03,4.36,2.20, 
      1.83,12.98,9.50,2.33,10.39, 10.08,6.80,6.28,3.84,10.08,12.96, 
      14.29,4.49,4.23,8.33,3.00,9.52,8.33,3.00,9.52) 

# plot 
z = c(" "," "," "," "," "," "," "," "," "," "," ") 
x1 = seq(0.5, 32.5, 1) 
y1 = rep(0,33) 
x <- seq(1, 32, 1) 

the_plot <- function() 
{ 
    plot(x1, y1, ylim = c(0,25),xlab = " ",ylab = " ",type = "l", xaxt='n', 
     yaxt='n', main = " ") 
    points(x = x, y = ace_Obs, col = "black", cex = 1.5) 
    legend(x = -1.3, y = 25, "Nov", cex = 2.2, text.font=2, box.lwd = 1) 
    x2 = seq(1982,2013,3) 
    mtext(expression("ACE" ~ (m^{2} ~ s^{-1} ~ "")), 
     side=2,line=2.7, 
     font = 6, cex = 2) 
    axis(1,at=seq(1, 32, by=3), labels=x2, las=2, font = 6) 
    axis(2,at=seq(0,25, 5), labels=c("0","5","10","15","20","25"), 
     las=2, font = 6) 
} 

png("TEST.png",width = 6,height = 4,units = "in",res = 1000, pointsize = 6) 
par(mfrow = c(1,1), 
    oma = c(5,5,0,0) + 0.1, 
    mar = c(0.5,0.5,1,1) + 0.1, xaxs = "i", yaxs = "i", cex.axis = 2, 
    cex.lab = 2,cex.main = 2) 
the_plot() 
dev.off() 
+1

有一個看看'?par'。這裏的方便參考http://www.statmethods.net/advgraphs/parameters.html – infominer

+1

那麼,開始與沒有字體= 6(或至少我從來沒有見過一個。)圖形細節往往是OS和特定於設置,你沒有給我們的信息。請參閱'?Devices','?png','?X11','?X11Fonts'和'?par'。您可能需要更改「家庭」指定。其中一些繪圖功能將接受「家庭」參數,而不需要重新執行「par(...)」。您確實需要確保指定的家族可用於您選擇的設備 –

+1

我已經找到[extrafont](http://blog.revolutionanalytics.com/2012/09/how-to-use-your-favorite-fonts -in-r-charts.html)包是有幫助的。 –

回答

0

它可能會有所幫助的人,上面問這個問題(對於PNG出認沽)使用type = "cairo"如下:

png("GFDL_ace_Forecast11.png",width = 6,height = 8,units = "in",res = 1000, pointsize = 7, type = "cairo") 
相關問題