5
votes

I'd like to change the color and font size of:

  1. Xlab,
  2. Ylab,
  3. values of X and Y-axis
  4. Panel border (color)

in R plot Is there a way to do it?

3

3 Answers

14
votes

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

3
votes

Check out the ?par help page, as well as the relevant Quick-R tutorials for an overview of the parameters you can change to embellish or annotate a base R plot.

2
votes

Ok, first timer here so please be generous with positive votings :)

Other than ggplot2 I dont think you need anything fancy. Here is a Time-Series-Plot for your panel-background, axis-text and axis-title aaaand some way to add nice vertical lines to mark important days.

your_data%>%
  ggplot(aes(x=Date, y=Transactions))+geom_line(colour='gold', size=1)+
  theme(panel.background = element_rect(fill='#363636'), plot.background = element_rect(fill='#363636'), 
        axis.text = element_text(colour='white', size = 10), axis.title = element_text(colour='white', size=12), 
        plot.title = element_text(colour='white'))+
  geom_vline(xintercept = as.Date(c('2020-11-08', '2020-11-29')), col='red', size=1)+
  labs(title='Abokäufe insgesammt')