It occurred to me after my initial post that you will need a little more
"fixing" of your axis labels if you have data that is not trivial integers
as in your example. Consider the following solution for some irrational
random numbers:
dat=rnorm(20)
dat1=dat-min(dat)
barplot(dat1,axes=FALSE)
axis(2, round(seq(from=min(dat1),to=max(dat1),length.out=10), digits=1),
round(seq(from=min(dat),to=max(dat),length.out=10), digits=1))
Rob Baer
I believe that you will have to draw them in ggplot2 as someone mentioned
or in base graphics. Here is a rough first attempt that may give you some
ideas.
================================
xx <- -3:4
yy <- rep(-3,length(xx))
plot(xx,xx, type="n", xlim=c(-4, 5))
rect(xx, yy, xx+.5, xx )
================================
--- On Fri, 9/3/10, Zoppoli, Gabriele (NIH/NCI) [G]
<zoppo...@mail.nih.gov> wrote:
From: Zoppoli, Gabriele (NIH/NCI) [G] <zoppo...@mail.nih.gov>
Subject: [R] how can I plot bar plots with all the bars (negative and
positive) in the same direction????
To: "r-help@r-project.org" <r-help@r-project.org>
Received: Friday, September 3, 2010, 1:12 PM
Dear r-help mailing list,
this seems stupid, but I actually don't find the solution:
if I have a vector of numbers x of length n, ranging, say,
from -3 to 4, if I do
barplot (x)
all the values below 0 go downwards, and all the positive
values go upward. How can I make them all begin from the
minimum pointing upwards?
Thanks!
Gabriele Zoppoli, MD
Ph.D. Fellow, Experimental and Clinical Oncology and
Hematology, University of Genova, Genova, Italy
Guest Researcher, LMP, NCI, NIH, Bethesda MD
Work: 301-451-8575
Mobile: 301-204-5642
Email: zoppo...@mail.nih.gov
______________________________________________
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.
______________________________________________
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.
______________________________________________
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.