I'd like to change the color and font size of:
in R plot Is there a way to do it?
How to change font size in r? To change the font size of text, use cex (character expansion ratio). The default value is 1. To reduce the text size, use a cex value of less than 1; to increase the text size, use a cex value greater than 1.
To change the color of X-axis label using ggplot2, we can use theme function that has axis. title. x argument which can be used for changing the color of the label values.
Go to the menu in RStudio and click on Tools and then Global Options. Select the Appearance tab on the left. Again buried in the middle of things is the font size. Change this to 14 or 16 to start with and see what it looks like.
The most basic graphics function in R is the plot function. This function has multiple arguments to configure the final plot: add a title, change axes labels, customize colors, or change line types, among others.
Here's code demonstrating some of the lower level plotting functions that provide the sort of fine-grained control that you're wanting. See the help pages of the several functions for even more options.
plot(rnorm(99), bty="n", axes=FALSE, xlab="", ylab="")
box(col="dodgerblue")
axis(1, col="dodgerblue", col.ticks="green", col.axis="orange", cex.axis=2)
axis(2, col="dodgerblue", col.ticks="green", col.axis="orange", cex.axis=0.8)
mtext("Index", side=1, line=3, col="red", cex=2)
mtext("Value", side=2, line=3, col="purple", cex=0.8)
(The resulting plot is ugly enough that I'll let you run the code yourself, rather than reproduce it here!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With