r-help Trying to figure out how to plot by month bar charts. The follow code plots the monthly portion on a yearly x-scale. So I either I create 12 individual month plots or maybe there is some sort of "break" to tell R separate by month and use the months dates as the x-scale; so that Jan's scale is 1 - 31 Jan , Feb scale is 1 - 28 Feb etc. As it is now I get the Jan values ploted with a 1-Jan to 31 Dec x-scale; Feb's value are ploted on a 1-Jan to 31 Dec x-scale etc. ggplot(data = df, aes(x = date, y = height)) + geom_bar(stat = "identity") + geom_bar(aes(x = action, y = height), color = "red", stat "identity") + facet_wrap(~month, nrow = 3) Jeff [[alternative HTML version deleted]]
For this kind of plot I usually use day-of-month for for the x-axis instead of a date or timestamp. -- Sent from my phone. Please excuse my brevity. On May 9, 2017 6:55:27 PM PDT, Jeff Reichman <reichmanj at sbcglobal.net> wrote:>r-help > > > >Trying to figure out how to plot by month bar charts. The follow code >plots >the monthly portion on a yearly x-scale. So I either I create 12 >individual >month plots or maybe there is some sort of "break" to tell R separate >by >month and use the months dates as the x-scale; so that Jan's scale is 1 >- 31 >Jan , Feb scale is 1 - 28 Feb etc. As it is now I get the Jan values >ploted >with a 1-Jan to 31 Dec x-scale; Feb's value are ploted on a 1-Jan to 31 >Dec >x-scale etc. > > > >ggplot(data = df, aes(x = date, y = height)) + > > geom_bar(stat = "identity") + > > geom_bar(aes(x = action, y = height), color = "red", stat >"identity") + > > facet_wrap(~month, nrow = 3) > > > >Jeff > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
Could we see some sample data? On Tuesday, May 9, 2017 9:55 PM, Jeff Reichman <reichmanj at sbcglobal.net> wrote: r-help Trying to figure out how to plot by month bar charts. The follow code plots the monthly portion on a yearly x-scale.? So I either I create 12 individual month plots or maybe there is some sort of "break" to tell R separate by month and use the months dates as the x-scale; so that Jan's scale is 1 - 31 Jan , Feb scale is 1 - 28 Feb etc.? As it is now I get the Jan values ploted with a 1-Jan to 31 Dec x-scale; Feb's value are ploted on a 1-Jan to 31 Dec x-scale etc. ggplot(data = df, aes(x = date, y = height)) + ? ? ? ? geom_bar(stat = "identity") + ? ? ? ? geom_bar(aes(x = action, y = height), color = "red", stat "identity") + ? ? ? ? facet_wrap(~month, nrow = 3) Jeff ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
Does scale_x_date(date_breaks = "1 month") do what you want? Ulrik John Kane via R-help <r-help at r-project.org> schrieb am Sa., 13. Mai 2017, 17:12:> Could we see some sample data? > > > On Tuesday, May 9, 2017 9:55 PM, Jeff Reichman < > reichmanj at sbcglobal.net> wrote: > > > r-help > > > > Trying to figure out how to plot by month bar charts. The follow code plots > the monthly portion on a yearly x-scale. So I either I create 12 > individual > month plots or maybe there is some sort of "break" to tell R separate by > month and use the months dates as the x-scale; so that Jan's scale is 1 - > 31 > Jan , Feb scale is 1 - 28 Feb etc. As it is now I get the Jan values > ploted > with a 1-Jan to 31 Dec x-scale; Feb's value are ploted on a 1-Jan to 31 Dec > x-scale etc. > > > > ggplot(data = df, aes(x = date, y = height)) + > > geom_bar(stat = "identity") + > > geom_bar(aes(x = action, y = height), color = "red", stat > "identity") + > > facet_wrap(~month, nrow = 3) > > > > Jeff > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]