Reformatting x and y-axis in ggplot2

Hi, I have created this plot, using the following code.

TSSConc.dat <- read.csv("TSSConcentrationDataRev.csv")
TSSConc.dat

ggplot() +
  geom_bar(data = df, aes(x = Date, y = value, fill = name), 
           stat = 'identity', 
           position = 'dodge')  

I would like to reformat the y-axis to have a logarithmic scale (increasing the readability of the small values on the left of the plot), and reformat the x-axis so that it shows fewer dates. Does anyone have any advice on how to achieve this? TIA

Additionally if someone knows how to customize the colours of the bars that would be great. I want C1In1, C1In2 and C1Out to be three different shades of blue, C2In and C2Out to be two different shades of red, and C3 in and C3Out to be three different shades of green.

I also want to change the font of the plot to Times New Roman

Your dates are being read as characters. To make them numeric dates, you can use the ymd() function from the lubridate package.
A log y scale is made with scale_y_log10().
The color of the fill can be controlled with scale_fill_manual(). Colors can be entered as names or as hex values.

library(lubridate)
library(ggplot2)
DF <- data.frame(Date = c("2023-01-07", "2023-04-14", "2023-05-06"),
                 name = c("C1in", "C1out", "C2in"),
                 value = c(3, 400, 20))
DF$Date <- ymd(DF$Date)
ggplot(DF, aes(x = Date, y = value, fill = name)) + geom_col() +
  scale_y_log10() +
  scale_fill_manual(values = c(C1in = "skyblue", C1out = "steelblue",
                               C2in = "#CC0000"))

you likely have to do additional summarisation so that this makes sense. perhaps by month or by quarter.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.