[R] Overlapping barplots and lines

Uwe Ligges ||gge@ @end|ng |rom @t@t|@t|k@tu-dortmund@de
Thu Sep 15 08:04:24 CEST 2022



On 15.09.2022 07:46, Stefano Sofia wrote:
> Dear R-list users,
> 
> I have a silly problem with plot that I am not able to solve. I tried to find a solution through the web, with no success.
> 
> 
> I need to overlap a barplot with points:
> 
> 
> barplot(c(55, 80, 120, 90, 105), lwd=1, lend=1, main="", ylab="cm", width=1, ylim=c(0, 120), axes=F)

with

bp <- barplot(c(55, 80, 120, 90, 105), lwd=1, lend=1, main="", 
ylab="cm", width=1, ylim=c(0, 120), axes=F)

you store the locations of the bars.
Then:

lines(bp, c(70, 50, 100, 60, 70), type="p", pch=21, bg="red")


Best,
Uwe Ligges

> lines(c(70, 50, 100, 60, 70), type="p", pch=21, bg="red")
> 
> axis(1, at=c(1, 2, 3, 4, 5), labels=c("Dec", "Jan", "Feb", "Mar", "Apr"), pos=-1, cex.axis=0.8)
> axis(2, at=seq(0, 120, 10), pos=0)
> 
> 
> Points and x-axis are not centered with barplots. How can I fix it?
> 
> 
> Thank you for your help
> 
> Stefano
> 
> 
>           (oo)
> --oOO--( )--OOo--------------------------------------
> Stefano Sofia PhD
> Civil Protection - Marche Region - Italy
> Meteo Section
> Snow Section
> Via del Colle Ameno 5
> 60126 Torrette di Ancona, Ancona (AN)
> Uff: +39 071 806 7743
> E-mail: stefano.sofia using regione.marche.it
> ---Oo---------oO----------------------------------------
> 
> ________________________________
> 
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu� contenere informazioni confidenziali, pertanto � destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si � il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si � ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit� ed urgenza, la risposta al presente messaggio di posta elettronica pu� essere visionata da persone estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system.
> 
> --
> 
> Questo messaggio  stato analizzato da Libraesva ESG ed  risultato non infetto.
> 
> This message was scanned by Libraesva ESG and is believed to be clean.
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help using 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.



More information about the R-help mailing list