Thanks everyone. It helped.

________________________________
From: Jim Lemon <drjimle...@gmail.com>
Sent: Monday 18 October 2021 04:01
To: Eliza Botto <eliza_bo...@outlook.com>; r-help mailing list 
<r-help@r-project.org>
Subject: Re: [R] Rising and falling bar-plots simultaneously

Hi Eliza,
Try this:

BAS1<-
structure(c(3, 4, 2, 3, 3, 4, 3, 3, 3, 3, 2, 3, 3, 4, 3, 2, 2,
3, 2, 3, 3, 3, 4, 5, 3, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 4, 3, 3,
3, 4, 3, 3, 4, 5, 4, 4, 4, 3, 4, 3, 3, 3, 3, 4, 4, 5, 4, 3, 4,
4, 2, 3, 3, 3, 2, 4, 4, 3, 3, 4, 3, 3, 3, 3, 4, 4, 3, 3, 2, 3,
3, 3, 3, 2, 5, 2, 4, 3, 2, 3, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 2,
3, 4, 3, 4, 4, 3, 3, 3, 3, 5, 3, 3, 5, 3, 4, 2, 3, 3, 3, 3, 3,
4, 3, 3.93, 3.509, 2.464, 2.72, 2.304, 3.517, 3.517, 6.675, 6.597,
2.715, 2.849, 2.618, 3.126, 2.715, 3.931, 3.709, 3.931, 4.145,
6.585, 3.907, 3.132, 2.568, 3.883, 2.447, 3.517, 7.098, 3.027,
3.003, 7.098, 2.374, 2.065, 2.95, 3.559, 5.102, 3.907, 3.204,
3.207, 2.791, 2.116, 3.003, 3.003, 3.003, 6.049, 3.52, 2.241,
3.883, 4.145, 3.334, 3.151, 6.269, 4.04, 3.883, 2.27, 3.304,
2.464, 4.111, 2.728, 3.93, 3.911, 2.447, 3.202, 2.375, 2.442,
2.442, 2.592, 2.13, 3.122, 5.657, 6.076, 4.186, 2.115, 2.623,
6.076, 2.467, 2.623, 2.629, 2.517, 2.623, 2.517, 4.32, 4.045,
6.597, 4.079, 3.817, 3.521, 2.564, 3.071, 2.447, 3.334, 2.442,
2.248, 3.094, 4.045, 4.045, 2.252, 2.971, 3.727, 2.184, 2.783,
2.849, 3.529, 2.484, 2.184, 2.313, 2.512, 3.4, 4.096, 3.572,
2.663, 3.405, 5.102, 3.267, 2.987, 2.123, 3.47, 2.512, 2.783,
6.597, 6.435, 4.921, 3.351, 2.07, 2.07, 2.442), .Dim = c(124L,
2L))
library(plotrix)
x11(width=12,height=5)
barp(BAS1[,1],main="Plot of BAS1",ylim=c(0,10),col="green")
plotlim<-par("usr")
rect(seq(0.6,123.6,1),plotlim[4]-BAS1[,2],
 seq(1.4,124.4,1),plotlim[4],col="red")

This clearly needs refinement, but it's a start.

Jim

On Mon, Oct 18, 2021 at 12:15 PM Eliza Botto <eliza_bo...@outlook.com> wrote:
>
> Dear useRs,
>
> Sorry for a very basic question. I have the following data set containing 2 
> columns.
>
> > dput(BAS1)
>
> structure(c(3, 4, 2, 3, 3, 4, 3, 3, 3, 3, 2, 3, 3, 4, 3, 2, 2,
> 3, 2, 3, 3, 3, 4, 5, 3, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 4, 3, 3,
> 3, 4, 3, 3, 4, 5, 4, 4, 4, 3, 4, 3, 3, 3, 3, 4, 4, 5, 4, 3, 4,
> 4, 2, 3, 3, 3, 2, 4, 4, 3, 3, 4, 3, 3, 3, 3, 4, 4, 3, 3, 2, 3,
> 3, 3, 3, 2, 5, 2, 4, 3, 2, 3, 4, 3, 4, 4, 3, 4, 4, 3, 3, 3, 2,
> 3, 4, 3, 4, 4, 3, 3, 3, 3, 5, 3, 3, 5, 3, 4, 2, 3, 3, 3, 3, 3,
> 4, 3, 3.93, 3.509, 2.464, 2.72, 2.304, 3.517, 3.517, 6.675, 6.597,
> 2.715, 2.849, 2.618, 3.126, 2.715, 3.931, 3.709, 3.931, 4.145,
> 6.585, 3.907, 3.132, 2.568, 3.883, 2.447, 3.517, 7.098, 3.027,
> 3.003, 7.098, 2.374, 2.065, 2.95, 3.559, 5.102, 3.907, 3.204,
> 3.207, 2.791, 2.116, 3.003, 3.003, 3.003, 6.049, 3.52, 2.241,
> 3.883, 4.145, 3.334, 3.151, 6.269, 4.04, 3.883, 2.27, 3.304,
> 2.464, 4.111, 2.728, 3.93, 3.911, 2.447, 3.202, 2.375, 2.442,
> 2.442, 2.592, 2.13, 3.122, 5.657, 6.076, 4.186, 2.115, 2.623,
> 6.076, 2.467, 2.623, 2.629, 2.517, 2.623, 2.517, 4.32, 4.045,
> 6.597, 4.079, 3.817, 3.521, 2.564, 3.071, 2.447, 3.334, 2.442,
> 2.248, 3.094, 4.045, 4.045, 2.252, 2.971, 3.727, 2.184, 2.783,
> 2.849, 3.529, 2.484, 2.184, 2.313, 2.512, 3.4, 4.096, 3.572,
> 2.663, 3.405, 5.102, 3.267, 2.987, 2.123, 3.47, 2.512, 2.783,
> 6.597, 6.435, 4.921, 3.351, 2.07, 2.07, 2.442), .Dim = c(124L,
> 2L))
>
> I want to draw bar chart in such a way that column 1 is drawn on primary y 
> axis with bars rising, while the column 2 is draw on a secondary y axis with 
> bar-plots falling down from the top exactly on the top of rising bars. For 
> example, the plot of 1st row of column one should be overshadowed by the bar 
> of 1st row of column 2. Additionally, I want all the bars to be red while 3rd 
> and 102nd bar of rising and falling bars to be coloured green.
>
> I hope I am clear 🙂. Thank-you very much in advance.
>
>
>
> regards,
>
> Eliza
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to