Skip to content
Prev 26730 / 29559 Next

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 at r-project.org> wrote:

            

  
  
Message-ID: <CAM+rpYmfnsiEP=yAspUAV_7Sho=9E=Kr0OfN+6toPeUwAbC6gw@mail.gmail.com>
In-Reply-To: <20180813102509.E59BD4F6@hypatia.math.ethz.ch>