简体   繁体   中英

decrease x-axis font on a plot in R

I would like to decrease the font size of the x-axis so it fits the country names.

I have tried cex , cex.axis , axis() and nothing has seemed to work. cex and cex.axis have changed the Y-axis only. Here is the code I have been using.

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),)

This may not apply directly to this question, but the solution when working with dates is to initially suppress x-axis labels and subsequently plot the x-axis with the axis.Date() command. This requires creating a separate x-axis data set--in the example below this is generated in the dates file. Here's an example by plotting stock market data (S&P 500). Note the xaxt="n" parameter in plot() and the relatively small font size in axis.Date() via cex.axis=0.8

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM