[R] Over lay 2 scale in same plot

Joshua Wiley jwiley.psych at gmail.com
Wed Sep 8 17:07:06 CEST 2010


Hi Mamum,

The co-ordinates appear shifted because the bars are not centered at
1, 2, 3, etc.  To give an example:

# Create a barplot
# of the numbers 1 through 10
barplot(1:10)

# Now look at the x axis coordinates of these actual bars
barplot(1:10, plot = FALSE)

# One way to get these coordinates for yourself would be
x <- barplot(1:10) # this will plot AND save the object
x # see the coordinates

# This should have the points properly centered with the bars
points(x = x, y = 10:1)

HTH,

Josh

On Wed, Sep 8, 2010 at 6:14 AM, mamunbabu2001 <mrashid_9 at hotmail.com> wrote:
>
> Hi Peng,
> Thanks for your reply. I have tried it and it does work fine
> apart from one problem. Even though the second data set
> has same length as the first one, the point function seems
> to shit all the points towards left side. So the points are not
> in concordat  co-ordinates as the bars. Any idea how this can
> be fixed ???
>
> thanks in advace.
>
> regards,
> Mamun
> --
> View this message in context: http://r.789695.n4.nabble.com/Over-lay-2-scale-in-same-plot-tp2528661p2531255.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list