r - Overlay barplot with 2 y Axis -


i want barplot overlays 2 variables (2 y axis).

this plot

enter image description here

and im looking for.

enter image description here

here data.

what used make plot.

ylim3 <- max(mesbar) + 2000 mesbar <- c(total_septiembre, total_octubre) barplot(mesbar, main = "month income",         ylim = c(0,ylim3)) grid()  > mesbar [1]  1260 12710 

and want overlapp data (days worked)

> dias_trabajados_sep [1] 2 > dias_trabajados_oct [1] 22 

it can done. however, keep in mind playing axis ylims , viewers misleading. trick add par(new = true) , new barplot. chose add blue color trough rgb allows transparency trough alpha argument. useful when gray bars shorter blue bars.

mesbar <-c(1260,12710) dias <- c(2,22) ylim3 <- max(mesbar) + 2000 #mesbar <- c(total_septiembre, total_octubre) barplot(mesbar, main = "month income",         ylim = c(0,ylim3)) grid() par(new = true) barplot(dias, main = "month income", col=rgb(0,0,1, alpha=.5),xaxt = "n",yaxt="n",xlab="",ylab="", ylim=c(0,30)) axis(side=4) 

enter image description here


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -