Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor
Hi Victor, See http://bm2.genes.nig.ac.jp/RGM2/R_current/library/plotrix/man/pyramid.plot.html <http://bm2.genes.nig.ac.jp/RGM2/R_current/library/plotrix/man/pyramid.plot.html> HTH, Jorge On Thu, Jul 9, 2009 at 12:24 AM, Victor Manuel Garcia Guerrero < vmgarcia@colmex.mx> wrote:> Hi, I hope somebody can help me with this issue: I am doing population > pyramids using the barplot command, so in the left side I have male age > structure and in the right side the female age structure. To plot the male > age structure I put the data in negative numbers. Now, I want to change the > sign in the bar plot in such way that I have no-sign numbers, both in left > and right side of the graph. I have been trying all day long and I could not > succed. > > Thanks... > > Victor > > ______________________________________________ > R-help@r-project.org mailing list > 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]]
have you tried the pyramid function in the epicalc package? best, daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Victor Manuel Garcia Guerrero Gesendet: Thursday, July 09, 2009 12:25 AM An: r-help at r-project.org Betreff: [R] Population pyramids Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor ______________________________________________ R-help at r-project.org mailing list 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.
Thanks Jorge, this is a very good library, but I have been trying with barplot because I am doing population pyramids with confidence intervals. So, the pyramid function does not work with more than two colum matrix. -----Mensaje original----- De: Jorge Ivan Velez [mailto:jorgeivanvelez at gmail.com] Enviado el: mi? 08/07/2009 11:32 Para: Victor Manuel Garcia Guerrero CC: r-help at r-project.org Asunto: Re: [R] Population pyramids Hi Victor, See http://bm2.genes.nig.ac.jp/RGM2/R_current/library/plotrix/man/pyramid.plot.html <http://bm2.genes.nig.ac.jp/RGM2/R_current/library/plotrix/man/pyramid.plot.html> HTH, Jorge On Thu, Jul 9, 2009 at 12:24 AM, Victor Manuel Garcia Guerrero < vmgarcia at colmex.mx> wrote:> Hi, I hope somebody can help me with this issue: I am doing population > pyramids using the barplot command, so in the left side I have male age > structure and in the right side the female age structure. To plot the male > age structure I put the data in negative numbers. Now, I want to change the > sign in the bar plot in such way that I have no-sign numbers, both in left > and right side of the graph. I have been trying all day long and I could not > succed. > > Thanks... > > Victor > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
Yes, but my issue is because I need to plot a pop pyramid with confidence intervals, and the pyramid function does not work in that way. Thanks Daniel. -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: mi? 08/07/2009 11:36 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids have you tried the pyramid function in the epicalc package? best, daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Victor Manuel Garcia Guerrero Gesendet: Thursday, July 09, 2009 12:25 AM An: r-help at r-project.org Betreff: [R] Population pyramids Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor ______________________________________________ R-help at r-project.org mailing list 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.
Can you provide a self-contained example of what you did so far (i.e. code for simulating some data and code for the plot)? That would greatly help to help you find a solution. Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: Victor Manuel Garcia Guerrero [mailto:vmgarcia at colmex.mx] Gesendet: Thursday, July 09, 2009 12:48 AM An: Daniel Malter; r-help at r-project.org Betreff: RE: [R] Population pyramids Yes, but my issue is because I need to plot a pop pyramid with confidence intervals, and the pyramid function does not work in that way. Thanks Daniel. -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: mi? 08/07/2009 11:36 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids have you tried the pyramid function in the epicalc package? best, daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Victor Manuel Garcia Guerrero Gesendet: Thursday, July 09, 2009 12:25 AM An: r-help at r-project.org Betreff: [R] Population pyramids Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor ______________________________________________ R-help at r-project.org mailing list 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.
Yes the code is the next: par(mfrow=c(1,2),bty="n",mai=c(0.5, 0.25, 0.25, 0.25)) barplot(height=t(icNM2005.dat), width = 0.825, space = NULL, names.arg = NULL, legend.text = NULL, beside = FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Hombres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axes = FALSE, axisnames = FALSE,cex.axis=0.75) axis(1,pretty(c(-1200,0),n=12), hadj=NA,padj=NA,cex.axis=0.75,las=2) barplot(height=t(icNF2005.dat), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axes = FALSE, axisnames = FALSE,cex.axis=0.75) axis(2,pretty(c(0:105),n=21),hadj=0.5,padj=0.5,cex.axis=0.75, las=2) axis(1,pretty(c(0:1200),n=5), hadj=NA,padj=NA,cex.axis=0.5,las=1) V?ctor Manuel Garc?a Guerrero Doctorado en Estudios de Poblaci?n, CEDUA, COLMEX Camino al Ajusco N? 20, Pedregal de Sta. Teresa C.P.10740, Tlalpan, M?xico, D.F. * : vmgarcia at colmex.mx ( : 5617-9016 -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: jue 09/07/2009 12:15 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids Can you provide a self-contained example of what you did so far (i.e. code for simulating some data and code for the plot)? That would greatly help to help you find a solution. Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: Victor Manuel Garcia Guerrero [mailto:vmgarcia at colmex.mx] Gesendet: Thursday, July 09, 2009 12:48 AM An: Daniel Malter; r-help at r-project.org Betreff: RE: [R] Population pyramids Yes, but my issue is because I need to plot a pop pyramid with confidence intervals, and the pyramid function does not work in that way. Thanks Daniel. -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: mi? 08/07/2009 11:36 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids have you tried the pyramid function in the epicalc package? best, daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Victor Manuel Garcia Guerrero Gesendet: Thursday, July 09, 2009 12:25 AM An: r-help at r-project.org Betreff: [R] Population pyramids Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor ______________________________________________ R-help at r-project.org mailing list 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.
Victor Manuel Garcia Guerrero wrote:> Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. > >Hi Victor, I can get part of the way there with pyramid.plot and plotCI, but it would take some concentrated hacking to do it properly. If you can't find another solution, let me know. Jim
Victor, use the axes=FALSE option, as you do. Then use the "labels" and "at" options in the "axis" argument to place the tickmark labels in the negative plot manually par(mfrow=c(1,2),bty="n",mai=c(0.5, 0.25, 0.25, 0.25)) x=rgamma(1000,10,0.3) barplot(height=t(-x), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, horiz = TRUE, density = NULL, angle = 0, axes = FALSE, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axisnames = FALSE, axis(1,hadj=NA,padj=NA,cex.axis=0.75,labels=c("0","10","20","30","40","50"," 60","70"),at=c(0,-10,-20,-30,-40,-50,-60,-70))) barplot(height=t(x), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, axes=FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axisnames = FALSE, axis(1,cex.axis=0.75)) That should do. Best, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: Victor Manuel Garcia Guerrero [mailto:vmgarcia at colmex.mx] Gesendet: Thursday, July 09, 2009 1:44 AM An: Daniel Malter; r-help at r-project.org Betreff: RE: [R] Population pyramids Yes the code is the next: par(mfrow=c(1,2),bty="n",mai=c(0.5, 0.25, 0.25, 0.25)) barplot(height=t(icNM2005.dat), width = 0.825, space = NULL, names.arg = NULL, legend.text = NULL, beside = FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Hombres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axes = FALSE, axisnames = FALSE,cex.axis=0.75) axis(1,pretty(c(-1200,0),n=12), hadj=NA,padj=NA,cex.axis=0.75,las=2) barplot(height=t(icNF2005.dat), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axes = FALSE, axisnames = FALSE,cex.axis=0.75) axis(2,pretty(c(0:105),n=21),hadj=0.5,padj=0.5,cex.axis=0.75, las=2) axis(1,pretty(c(0:1200),n=5), hadj=NA,padj=NA,cex.axis=0.5,las=1) V?ctor Manuel Garc?a Guerrero Doctorado en Estudios de Poblaci?n, CEDUA, COLMEX Camino al Ajusco N? 20, Pedregal de Sta. Teresa C.P.10740, Tlalpan, M?xico, D.F. * : vmgarcia at colmex.mx ( : 5617-9016 -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: jue 09/07/2009 12:15 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids Can you provide a self-contained example of what you did so far (i.e. code for simulating some data and code for the plot)? That would greatly help to help you find a solution. Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: Victor Manuel Garcia Guerrero [mailto:vmgarcia at colmex.mx] Gesendet: Thursday, July 09, 2009 12:48 AM An: Daniel Malter; r-help at r-project.org Betreff: RE: [R] Population pyramids Yes, but my issue is because I need to plot a pop pyramid with confidence intervals, and the pyramid function does not work in that way. Thanks Daniel. -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: mi? 08/07/2009 11:36 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids have you tried the pyramid function in the epicalc package? best, daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Victor Manuel Garcia Guerrero Gesendet: Thursday, July 09, 2009 12:25 AM An: r-help at r-project.org Betreff: [R] Population pyramids Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor ______________________________________________ R-help at r-project.org mailing list 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.
Wonderful!!! It works!!! Thank you very much Daniel. I owe you one. Cheers Victor ________________________________ De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: jue 09/07/2009 10:44 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids Victor, use the axes=FALSE option, as you do. Then use the "labels" and "at" options in the "axis" argument to place the tickmark labels in the negative plot manually par(mfrow=c(1,2),bty="n",mai=c(0.5, 0.25, 0.25, 0.25)) x=rgamma(1000,10,0.3) barplot(height=t(-x), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, horiz = TRUE, density = NULL, angle = 0, axes = FALSE, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axisnames = FALSE, axis(1,hadj=NA,padj=NA,cex.axis=0.75,labels=c("0","10","20","30","40","50"," 60","70"),at=c(0,-10,-20,-30,-40,-50,-60,-70))) barplot(height=t(x), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, axes=FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axisnames = FALSE, axis(1,cex.axis=0.75)) That should do. Best, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: Victor Manuel Garcia Guerrero [mailto:vmgarcia at colmex.mx] Gesendet: Thursday, July 09, 2009 1:44 AM An: Daniel Malter; r-help at r-project.org Betreff: RE: [R] Population pyramids Yes the code is the next: par(mfrow=c(1,2),bty="n",mai=c(0.5, 0.25, 0.25, 0.25)) barplot(height=t(icNM2005.dat), width = 0.825, space = NULL, names.arg = NULL, legend.text = NULL, beside = FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Hombres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axes = FALSE, axisnames = FALSE,cex.axis=0.75) axis(1,pretty(c(-1200,0),n=12), hadj=NA,padj=NA,cex.axis=0.75,las=2) barplot(height=t(icNF2005.dat), width = 0.825, space = NULL, names.arg = NULL, legend.text = c("Inf 95%","Mediana","Sup 95%"), beside = FALSE, horiz = TRUE, density = NULL, angle = 0, col = c("yellow","Blue","orange"), border = par("fg"), main = "Mujeres", xlim =NULL, ylim = NULL, xpd = TRUE, log = "", axes = FALSE, axisnames = FALSE,cex.axis=0.75) axis(2,pretty(c(0:105),n=21),hadj=0.5,padj=0.5,cex.axis=0.75, las=2) axis(1,pretty(c(0:1200),n=5), hadj=NA,padj=NA,cex.axis=0.5,las=1) V?ctor Manuel Garc?a Guerrero Doctorado en Estudios de Poblaci?n, CEDUA, COLMEX Camino al Ajusco N? 20, Pedregal de Sta. Teresa C.P.10740, Tlalpan, M?xico, D.F. * : vmgarcia at colmex.mx ( : 5617-9016 -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: jue 09/07/2009 12:15 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids Can you provide a self-contained example of what you did so far (i.e. code for simulating some data and code for the plot)? That would greatly help to help you find a solution. Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: Victor Manuel Garcia Guerrero [mailto:vmgarcia at colmex.mx] Gesendet: Thursday, July 09, 2009 12:48 AM An: Daniel Malter; r-help at r-project.org Betreff: RE: [R] Population pyramids Yes, but my issue is because I need to plot a pop pyramid with confidence intervals, and the pyramid function does not work in that way. Thanks Daniel. -----Mensaje original----- De: Daniel Malter [mailto:daniel at umd.edu] Enviado el: mi? 08/07/2009 11:36 Para: Victor Manuel Garcia Guerrero; r-help at r-project.org Asunto: AW: [R] Population pyramids have you tried the pyramid function in the epicalc package? best, daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Victor Manuel Garcia Guerrero Gesendet: Thursday, July 09, 2009 12:25 AM An: r-help at r-project.org Betreff: [R] Population pyramids Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I have been trying all day long and I could not succed. Thanks... Victor ______________________________________________ R-help at r-project.org mailing list 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.