Re: [R-sig-Geo] How do i plot a graph with x axis vertically labelled?
The graphics parameters are all in the help file for par ?par The one you need is las. Without trying to wade thru your mangled HTML data (dput() is the best way to provide reproducible data), check this out: barplot(runif(5), names.arg = c("25/08/2004", "26/09/2004", "02/11/2004", "11/11/2004", "22/11/2004"), main = 'Females 2005', ylab = ' Age/Days', xlab = 'Birth/Hatch date', las=2) You'll need to mess with label positioning, and with margin size, to get everything looking as you wish. But I'm not sure this is the most effective way to show irregularly-spaced dates. Why not convert your dates to Date or other time series, and plot them to scale as points? Sarah On Mon, Aug 13, 2018 at 6:25 AM Vasana Tutjavi via R-sig-Geo wrote: > > Dear R-sig-geo experts, > > I want to plot a bar graph with the labels on the x axis in a vertical > format. The data is the Ages of Squid (on the Y axis) and the date of Birth > on the X axis, I am struggling to change the labels on the x axis to a > vertical format and I want all the dates to show at all the bars. My data is > as follows: > Birth > Sex > Age > 25/08/2004 > F > 2 > 26/09/2004 > F > 3 > 02/11/2004 > F > 3 > 11/11/2004 > F > 1 > 22/11/2004 > F > 3 > 04/12/2004 > F > 1 > 08/12/2004 > F > 4 > 15/12/2004 > F > 4 > 21/12/2004 > F > 5 > 24/12/2004 > F > 1 > 04/01/2005 > F > 1 > 06/01/2005 > F > 3 > 13/01/2005 > F > 2 > 18/01/2005 > F > 1 > 19/01/2005 > F > 3 > 09/02/2005 > F > 2 > 11/02/2005 > F > 1 > 13/02/2005 > F > 1 > 17/02/2005 > F > 1 > 18/02/2005 > F > 8 > 19/02/2005 > F > 5 > 24/02/2005 > F > 1 > 28/02/2005 > F > 42 > 01/03/2005 > F > 1 > 07/03/2005 > F > 1 > 08/03/2005 > F > 2 > 09/03/2005 > F > 1 > 14/03/2005 > F > 7 > 16/03/2005 > F > 1 > 25/03/2005 > F > 3 > 01/04/2005 > F > 1 > 06/04/2005 > F > 5 > 07/04/2005 > F > 1 > 08/04/2005 > F > 1 > 13/04/2005 > F > 1 > 14/04/2005 > F > 1 > 27/04/2005 > F > 1 > 01/05/2005 > F > 2 > 07/05/2005 > F > 1 > 08/05/2005 > F > 2 > 16/05/2005 > F > 1 > 30/05/2005 > F > 8 > 06/06/2005 > F > 1 > Here is the script I tried: > > barplot(Females2005$Age, names.arg = c("25/08/2004", "26/09/2004", > "02/11/2004", "11/11/2004", "22/11/2004", "04/12/2004", "08/12/2004", >"15/12/2004", "21/12/2004", > "24/12/2004", "04/01/2005", "06/01/2005", "13/01/2005", "18/01/2005", >"19/01/2005", "09/02/2005", > "11/02/2005", "13/02/2005", "17/02/2005", "18/02/2005", "19/02/2005", > "24/02/2005", "28/02/2005", > "01/03/2005", "07/03/2005", "08/03/2005", "09/03/2005", "14/03/2005", > "16/03/2005", "25/03/2005", "01/04/2005", > "06/04/2005", "07/04/2005", "08/04/2005", "13/04/2005", > "14/04/2005", "27/04/2005", > "01/05/2005", "07/05/2005", "08/05/2005", "16/05/2005", "30/05/2005", > "06/06/2005"), main = 'Females 2005', > ylab = 'Age/Days', xlab = 'Birth/Hatch date') > > Many thanks > Vasana > Sent from Mail for Windows 10 > > > [[alternative HTML version deleted]] > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Sarah Goslee http://www.functionaldiversity.org ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] How do i plot a graph with x axis vertically labelled?
Vasana-- May I ask why you want to produce such a graph? What relationship(s) in your data are you trying to show? I can't be sure from your original post, but it seems to me that you are trying to do this the hard way. R can help you. What happens when you run the code you posted? What error message do you get, if any? Your birthdates are not just nominal labels; they contain more information than that--specifically, they are ordered, with certain elapsed duration between them. Using them merely as names/labels on bars sacrifices information. Also, if you don't have an observation for every birthdate in a sequence of dates, then you will represent unequally-spaced dates with equally-spaced bars--generally not a good thing. Conversely, could any of your birthdates ever be duplicated? Vertically-oriented bar labels can be difficult for your intended audience to read, especially since you seem to want to put 30-40 of them along the horizontal axis. Another option would be to flip your graph, putting birthdates on the vertical axis so the date labels can be horizontal. Here is a minimal working example to demonstrate one possible solution that you might be able to modify to convey what you are trying to convey, and that let's R do the work it is good at. ## generate some data dd <- data.frame( birth = Sys.Date() + sort(sample(1:10, 6, replace = TRUE)), sex = factor(sample(c("M", "F"), 6, replace = TRUE)), age = sample(1:9, 6, replace = TRUE) ) ## show the data dd str(dd) ## a plot with(dd, plot(age ~ birth, type = "h")) --Chris Ryan On Mon, Aug 13, 2018 at 6:24 AM, Vasana Tutjavi via R-sig-Geo < r-sig-geo@r-project.org> wrote: > Dear R-sig-geo experts, > > I want to plot a bar graph with the labels on the x axis in a vertical > format. The data is the Ages of Squid (on the Y axis) and the date of Birth > on the X axis, I am struggling to change the labels on the x axis to a > vertical format and I want all the dates to show at all the bars. My data > is as follows: > Birth > Sex > Age > 25/08/2004 > F > 2 > 26/09/2004 > F > 3 > 02/11/2004 > F > 3 > 11/11/2004 > F > 1 > 22/11/2004 > F > 3 > 04/12/2004 > F > 1 > 08/12/2004 > F > 4 > 15/12/2004 > F > 4 > 21/12/2004 > F > 5 > 24/12/2004 > F > 1 > 04/01/2005 > F > 1 > 06/01/2005 > F > 3 > 13/01/2005 > F > 2 > 18/01/2005 > F > 1 > 19/01/2005 > F > 3 > 09/02/2005 > F > 2 > 11/02/2005 > F > 1 > 13/02/2005 > F > 1 > 17/02/2005 > F > 1 > 18/02/2005 > F > 8 > 19/02/2005 > F > 5 > 24/02/2005 > F > 1 > 28/02/2005 > F > 42 > 01/03/2005 > F > 1 > 07/03/2005 > F > 1 > 08/03/2005 > F > 2 > 09/03/2005 > F > 1 > 14/03/2005 > F > 7 > 16/03/2005 > F > 1 > 25/03/2005 > F > 3 > 01/04/2005 > F > 1 > 06/04/2005 > F > 5 > 07/04/2005 > F > 1 > 08/04/2005 > F > 1 > 13/04/2005 > F > 1 > 14/04/2005 > F > 1 > 27/04/2005 > F > 1 > 01/05/2005 > F > 2 > 07/05/2005 > F > 1 > 08/05/2005 > F > 2 > 16/05/2005 > F > 1 > 30/05/2005 > F > 8 > 06/06/2005 > F > 1 > Here is the script I tried: > > barplot(Females2005$Age, names.arg = c("25/08/2004", "26/09/2004", > "02/11/2004", "11/11/2004", "22/11/2004", "04/12/2004", "08/12/2004", >"15/12/2004", "21/12/2004", > "24/12/2004", "04/01/2005", "06/01/2005", "13/01/2005", "18/01/2005", >"19/01/2005", "09/02/2005", > "11/02/2005", "13/02/2005", "17/02/2005", "18/02/2005", "19/02/2005", > "24/02/2005", "28/02/2005", > "01/03/2005", "07/03/2005", "08/03/2005", "09/03/2005", "14/03/2005", > "16/03/2005", "25/03/2005", > "01/04/2005", "06/04/2005", "07/04/2005", "08/04/2005", "13/04/2005", > "14/04/2005", "27/04/2005", > "01/05/2005", "07/05/2005", "08/05/2005", "16/05/2005", "30/05/2005", > "06/06/2005"), main = 'Females 2005', > ylab = 'Age/Days', xlab = 'Birth/Hatch date') > > Many thanks > Vasana > Sent from Mail for Windows 10 > > > [[alternative HTML version deleted]] > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] How do i plot a graph with x axis vertically labelled?
Dear R-sig-geo experts, I want to plot a bar graph with the labels on the x axis in a vertical format. The data is the Ages of Squid (on the Y axis) and the date of Birth on the X axis, I am struggling to change the labels on the x axis to a vertical format and I want all the dates to show at all the bars. My data is as follows: Birth Sex Age 25/08/2004 F 2 26/09/2004 F 3 02/11/2004 F 3 11/11/2004 F 1 22/11/2004 F 3 04/12/2004 F 1 08/12/2004 F 4 15/12/2004 F 4 21/12/2004 F 5 24/12/2004 F 1 04/01/2005 F 1 06/01/2005 F 3 13/01/2005 F 2 18/01/2005 F 1 19/01/2005 F 3 09/02/2005 F 2 11/02/2005 F 1 13/02/2005 F 1 17/02/2005 F 1 18/02/2005 F 8 19/02/2005 F 5 24/02/2005 F 1 28/02/2005 F 42 01/03/2005 F 1 07/03/2005 F 1 08/03/2005 F 2 09/03/2005 F 1 14/03/2005 F 7 16/03/2005 F 1 25/03/2005 F 3 01/04/2005 F 1 06/04/2005 F 5 07/04/2005 F 1 08/04/2005 F 1 13/04/2005 F 1 14/04/2005 F 1 27/04/2005 F 1 01/05/2005 F 2 07/05/2005 F 1 08/05/2005 F 2 16/05/2005 F 1 30/05/2005 F 8 06/06/2005 F 1 Here is the script I tried: barplot(Females2005$Age, names.arg = c("25/08/2004", "26/09/2004", "02/11/2004", "11/11/2004", "22/11/2004", "04/12/2004", "08/12/2004", "15/12/2004", "21/12/2004", "24/12/2004", "04/01/2005", "06/01/2005", "13/01/2005", "18/01/2005", "19/01/2005", "09/02/2005", "11/02/2005", "13/02/2005", "17/02/2005", "18/02/2005", "19/02/2005", "24/02/2005", "28/02/2005", "01/03/2005", "07/03/2005", "08/03/2005", "09/03/2005", "14/03/2005", "16/03/2005", "25/03/2005", "01/04/2005", "06/04/2005", "07/04/2005", "08/04/2005", "13/04/2005", "14/04/2005", "27/04/2005", "01/05/2005", "07/05/2005", "08/05/2005", "16/05/2005", "30/05/2005", "06/06/2005"), main = 'Females 2005', ylab = 'Age/Days', xlab = 'Birth/Hatch date') Many thanks Vasana Sent from Mail for Windows 10 [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo