Skip to content

How to create axis y axis for horizontal bar plot?

5 messages · Robert Baer, Chris Campbell, Manish Gupta +1 more

#
Hi, 

i am working on bar plot but i need to generate y axis for horizontal bar
plot.  In the attached diagram x-axis is there with scale 0 to 12 but i need
y axis.  How can i implement it?

http://r.789695.n4.nabble.com/file/n4630478/barplot2.jpg 

Thanks

--
View this message in context: http://r.789695.n4.nabble.com/How-to-create-axis-y-axis-for-horizontal-bar-plot-tp4630478.html
Sent from the R help mailing list archive at Nabble.com.
#
-----Original Message----- 
From: Manish Gupta
Sent: Friday, May 18, 2012 2:52 AM
To: r-help at r-project.org
Subject: [R] How to create axis y axis for horizontal bar plot?

Hi,

i am working on bar plot but i need to generate y axis for horizontal bar
plot.  In the attached diagram x-axis is there with scale 0 to 12 but i need
y axis.  How can i implement it?

http://r.789695.n4.nabble.com/file/n4630478/barplot2.jpg

Thanks

Try:
gears = c(3,4,5)
b = barplot(gears, horiz=TRUE)
axis(2, at=b, labels=c('three','four','five'))

Rob
------------------------------------------
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965
#
# Hi Manish, try this

# locate the y axis central positions
barObj <- plot(factor(mtcars$gear, labels = paste(3:5, "Gears")), horiz = TRUE)

# create the plot
plot(factor(mtcars$gear, labels = paste(3:5, "Gears")), horiz = TRUE)
# add axes
axis(side = 2, at = c(barObj), labels = FALSE)




Chris Campbell
  
Tel. +44 (0) 1249 705 450
http://www.mango-solutions.com
Mango Solutions
2 Methuen Park
Chippenham
Wiltshire 
SN14 OGB
UK
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Manish Gupta
Sent: 18 May 2012 08:53
To: r-help at r-project.org
Subject: [R] How to create axis y axis for horizontal bar plot?

Hi, 

i am working on bar plot but i need to generate y axis for horizontal bar plot.  In the attached diagram x-axis is there with scale 0 to 12 but i need y axis.  How can i implement it?

http://r.789695.n4.nabble.com/file/n4630478/barplot2.jpg 

Thanks

--
View this message in context: http://r.789695.n4.nabble.com/How-to-create-axis-y-axis-for-horizontal-bar-plot-tp4630478.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.
LEGAL NOTICE
This message is intended for the use o...{{dropped:10}}
4 days later
#
On Wed, May 23, 2012 at 3:26 AM, Manish Gupta <mandecent.gupta at gmail.com> wrote:
I have no idea "what works," except that it may in some way relate to
bar plots, but in general xaxt="n" will remove an x axis. See ?par for
details.
Many of us don't use Nabble, and so if you don't include context in
your post we won't have the foggiest idea what you're talking about.