簡體   English   中英

減少R中繪圖上的x軸字體

[英]decrease x-axis font on a plot in R

我想減小x軸的字體大小,使其適合國家/地區名稱。

我已經嘗試過cexcex.axisaxis() ,但似乎沒有任何作用。 cexcex.axis僅更改了Y軸。 這是我一直在使用的代碼。

plot(goldmanMF20to50$Location, xlab="Location", ylab="Number of Individuals", 
     col=4, main="Location of Individuals in the Goldman Osteometric Data Set 
     between 20 and 50", cex.main=0.6, las = 2, ylim=c(0, 150),)

這可能並不直接適用於此問題,但是使用日期時的解決方案是首先隱藏x軸標簽,然后使用axis.Date()命令繪制x軸。 這需要創建一個單獨的x軸數據集-在下面的示例中,這是在date文件中生成的。 這是繪制股票市場數據(S&P 500)的示例。 注意plot()中的xaxt =“ n”參數,以及通過cex.axis = 0.8在axis.Date()中相對較小的字體大小

library(quantmod)

getSymbols("^GSPC", src='yahoo', from='2013-12-31')
sp500 <-Ad(GSPC)

dates <-as.Date(index(sp500))

plot(dates,sp500, ylab = "",xlab="",xaxt="n",type="l")
axis.Date(side = 1, dates,at = dates,cex.axis=0.8,format = "%b-%d-%Y")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM