Changing Date Graduation of a graph

Hi y'all!

I'm trying to change the graduation of the x axis of a graph I've done.
Here is the code I used to have my graph:

library(ggplot2)
library(tidyr)
library(tidyverse)

#Creating a data that will be used to plot the monhtly values
datatoplot <- monthly %>%
gather(Legend, Value, -Date)

#Plotting the graph
ggplot(datatoplot, aes(x = Date, y = Value, fill = Legend)) +
geom_bar(position = "dodge", stat = "identity") + theme_bw()

The x axis gives 2016, 2018,2020... when I really would like it to gives also the month, as it is a plot plotting monthly maximum and minimum.

here is my data.

MonthlyMax MonthlyMin       Date

1: 70.4 55.2 2015-01-01
2: 74.7 56.3 2015-02-01
3: 77.5 61.8 2015-03-01
4: 82.9 63.1 2015-04-01
5: 88.5 77.8 2015-05-01
6: 89.5 83.9 2015-06-01
7: 89.5 81.5 2015-07-01
8: 91.9 81.0 2015-08-01
9: 87.6 79.7 2015-09-01
10: 85.1 69.6 2015-10-01
11: 81.9 64.7 2015-11-01
12: 75.6 -99.0 2015-12-01
13: 72.0 40.2 2016-01-01
14: 75.5 48.9 2016-02-01
15: 76.2 -99.0 2016-03-01
16: 82.9 71.0 2016-04-01
17: 87.8 -99.0 2016-05-01
18: 89.9 80.2 2016-06-01
19: 91.7 83.0 2016-07-01
20: 89.1 80.6 2016-08-01
21: 90.4 -99.0 2016-09-01
22: 85.6 75.7 2016-10-01
23: 81.3 -99.0 2016-11-01
24: 75.5 58.4 2016-12-01
25: 73.5 58.4 2017-01-01
26: 71.3 51.7 2017-02-01
27: 75.4 60.9 2017-03-01
28: 82.7 66.9 2017-04-01
29: 85.8 75.9 2017-05-01
30: 88.8 80.2 2017-06-01
Thanks for the help!

Is this what you mean?

library(tidyverse)

# Sample data on a copy/paste friendly format (replace with your actual data frame)
monthly <- data.frame(
  MonthlyMax = c(70.4,74.7,77.5,82.9,88.5,89.5,89.5,
                 91.9,87.6,85.1,81.9,75.6,72,75.5,76.2,82.9,87.8,89.9,
                 91.7,89.1,90.4,85.6,81.3,75.5,73.5,71.3,75.4,82.7,
                 85.8,88.8),
  MonthlyMin = c(55.2,56.3,61.8,63.1,77.8,83.9,81.5,
                 81,79.7,69.6,64.7,-99,40.2,48.9,-99,71,-99,80.2,83,
                 80.6,-99,75.7,-99,58.4,58.4,51.7,60.9,66.9,75.9,80.2),
        Date = as.Date(c("2015-01-01","2015-02-01","2015-03-01",
                 "2015-04-01","2015-05-01","2015-06-01","2015-07-01",
                 "2015-08-01","2015-09-01","2015-10-01","2015-11-01","2015-12-01",
                 "2016-01-01","2016-02-01","2016-03-01","2016-04-01",
                 "2016-05-01","2016-06-01","2016-07-01","2016-08-01","2016-09-01",
                 "2016-10-01","2016-11-01","2016-12-01","2017-01-01",
                 "2017-02-01","2017-03-01","2017-04-01","2017-05-01","2017-06-01"))
)

monthly %>%
    gather(Legend, Value, -Date) %>% 
    ggplot(aes(x = Date, y = Value, fill = Legend)) +
    geom_bar(position = "dodge", stat = "identity") +
    scale_x_date(date_breaks = "month", date_labels = "%Y-%b") +
    theme_bw() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))

Created on 2020-11-22 by the reprex package (v0.3.0.9001)

Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.

Yes, that's the result I want. However, I didn't give the full data, just an extract. Do I need to do it by end or is there another way to have the same result quicker?

I'm new on this community and I'm not sure to know what's a reprex...

Can you clarify? I don't understand your question.

Click on the link I gave you and read the reprex guide so you can understand.

Do I have to do it by hand* sorry I meant

I still don't understand what you mean by that, exactly what part you would be doing "by hand"?

This topic was automatically closed 21 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.