Hello, I have a barplot where each row has quite long texts and I have used "par" to make some room in the left: par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, main = l, col=colores, horiz=TRUE,las=1, cex.names=.7) My problem is that main text appears justified to the plot. I want to put it in the middle of the image, and find a way to sort it out with mtex par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, col=colores, horiz=TRUE,las=1, cex.names=.7) mtext(l,side = 3, at = -70, line = 0.8) But I will have to adjust this "at =-70" to his plot, depending on the length of the title. I wonder if I can't find a way to place it in the center. Many thanks, R -- View this message in context: http://r.789695.n4.nabble.com/Positioning-main-title-tp4583663p4583663.html Sent from the R help mailing list archive at Nabble.com.
Positioning main title
5 messages · ramonovelar, Gerrit Eichner, Jim Lemon +2 more
Hello, R, check argument adj of mtext(). Hth -- Gerrit
I have a barplot where each row has quite long texts and I have used "par" to make some room in the left: par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, main = l, col=colores, horiz=TRUE,las=1, cex.names=.7) My problem is that main text appears justified to the plot. I want to put it in the middle of the image, and find a way to sort it out with mtex par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, col=colores, horiz=TRUE,las=1, cex.names=.7) mtext(l,side = 3, at = -70, line = 0.8) But I will have to adjust this "at =-70" to his plot, depending on the length of the title. I wonder if I can't find a way to place it in the center. Many thanks, R -- View this message in context: http://r.789695.n4.nabble.com/Positioning-main-title-tp4583663p4583663.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
On 04/25/2012 12:28 AM, ramonovelar wrote:
Hello, I have a barplot where each row has quite long texts and I have used "par" to make some room in the left: par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, main = l, col=colores, horiz=TRUE,las=1, cex.names=.7) My problem is that main text appears justified to the plot. I want to put it in the middle of the image, and find a way to sort it out with mtex par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, col=colores, horiz=TRUE,las=1, cex.names=.7) mtext(l,side = 3, at = -70, line = 0.8) But I will have to adjust this "at =-70" to his plot, depending on the length of the title. I wonder if I can't find a way to place it in the center.
Hi Ramon, Have a look at the getFigCtr function in the plotrix package. This returns the center of the figure region by default, but can be adjusted to return different proportions of the figure region. Jim
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120425/11f1ad9d/attachment.pl>
1 day later
You could also use the grconvertX function to convert from the middle of the plotting region (from='npc') to user coordinates (to='user'), or many other combinations.
On Wed, Apr 25, 2012 at 5:53 AM, Ramon Ovelar <ramon.ovelar at gmail.com> wrote:
Many many thanks for the tip and for authoring this function! The final code for the plot goes like this: par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, ?col=colores, horiz=TRUE,las=1, cex.names=.7) mtext(l,side = 3, at = getFigCtr()[1], line = 0.8, cex=1.5) On Wed, Apr 25, 2012 at 12:51 PM, Jim Lemon <jim at bitwrit.com.au> wrote:
On 04/25/2012 12:28 AM, ramonovelar wrote:
Hello, I have a barplot where each row has quite long texts and I have used "par" to make some room in the left: par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, main = l, col=colores, horiz=TRUE,las=1, cex.names=.7) My problem is that main text appears justified to the plot. I want to put it in the middle of the image, and find a way to sort it ?out with mtex par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0)) barplot2(prueba, ?col=colores, horiz=TRUE,las=1, cex.names=.7) mtext(l,side = 3, at = -70, line = 0.8) But I will have to adjust this "at =-70" to his plot, depending on the length of the title. I wonder if I can't find a way to place it in the center. ?Hi Ramon,
Have a look at the getFigCtr function in the plotrix package. This returns the center of the figure region by default, but can be adjusted to return different proportions of the figure region. Jim
-- ================================== Ram?n Ovelar ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ 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.
Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com