I used the following code to draw a scatterplot. How to increase the font size and change colour of x-axis and y-axis label?
data=read.csv("data.csv") plot(data$column1,data$column2,xlab="x axis", ylab="y axis", pch=19)
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.
To change the text font for any chart element, such as a title or axis, right–click the element, and then click Font. When the Font box appears make the changes you want.
Then, you can further adjust the font of code window, console, terminal, environment, and history panels via Tools >> Global Options >> Appearance >> Editor font size.
Look at ?par for the various graphics parameters.
In general cex controls size, col controls colour. If you want to control the colour of a label, the par is col.lab, the colour of the axis annotations col.axis, the colour of the main text, col.main etc. The names are quite intuitive, once you know where to begin.
For example
x <- 1:10 y <- 1:10 plot(x , y,xlab="x axis", ylab="y axis", pch=19, col.axis = 'blue', col.lab = 'red', cex.axis = 1.5, cex.lab = 2) 
If you need to change the colour / style of the surrounding box and axis lines, then look at ?axis or ?box, and you will find that you will be using the same parameter names within calls to box and axis.
You have a lot of control to make things however you wish.
eg
plot(x , y,xlab="x axis", ylab="y axis", pch=19, cex.lab = 2, axes = F,col.lab = 'red') box(col = 'lightblue') axis(1, col = 'blue', col.axis = 'purple', col.ticks = 'darkred', cex.axis = 1.5, font = 2, family = 'serif') axis(2, col = 'maroon', col.axis = 'pink', col.ticks = 'limegreen', cex.axis = 0.9, font =3, family = 'mono') 
Which is seriously ugly, but shows part of what you can control
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