Set border drawing for bars in a grid tablet

In my unsuccessful attempts to publish a document, I try to make the fantasy of infographics out of simple data in futile hope, to seduce reviewers with attractive images. As an option, I make histograms with an expanded line at the bottom of each bar, similar to those created by Nicholas Felton in this example ,

Thus, he is doing well, in general, mostly. But I use a very cheap trick to create these “extended borders” at the bottom of each bar. I add panel.abline(...)to an arbitrary place that roughly overlaps with the bottom of each bar. Let me illustrate:

data <- t(data.frame(urban = 10, suburban = 6, rural = 4))#exmaple data 
barchart(d, col="orange", xlim=c(0,15),
         scales=list(y=list(alternating=0)),#get rid of y-axis labels,
         border = "transparent",#make bars borders transprent
         par.settings = list(axis.line = list(col = "transparent")),
         panel = function(x,y,...) {
           panel.barchart(x,y,...)
           panel.abline(h=seq(0.66, 3.66,1), col="orange", lwd=0.7)#pathetic hack
           panel.axis(side=c("left"), at=1:3, half=F, ticks = F, 
                      outside=F, labels=rownames(d))

         })

leading to this histogram

enter image description here

, , , , , panel.abline , .. , . , - border ( transparent) , , pro. , .

, , , x = 0.

+4
1

, box.width . , , , :

panel = function(x, y, ...) {
  dots <- list(...)
  br <- dots$box.ratio
  panel.barchart(x, y, ...)
  panel.abline(h = seq_along(x) - 0.5*(br/(br+1)), col="orange", lwd=0.7)
}

:

d <- t(data.frame(urban = 10, suburban = 6, rural = 4, other=5))

barchart(d, col="orange", xlim=c(0, 15), box.ratio=5,
         scales=list(y=list(alternating=0)), 
         border = "transparent", 
         par.settings = list(axis.line = list(col = "transparent")), 
         panel = function(x, y, ...) {
           dots <- list(...)
           br <- dots$box.ratio
           panel.barchart(x, y, ...)
           panel.abline(h = seq_along(x) - 0.5*(br/(br+1)), col="orange", lwd=0.7)
         }
)

enter image description here


box.ratio:

d <- t(data.frame(urban = 10, suburban = 6, rural = 4, other=5, rubbish=7))

barchart(d, col="orange", xlim=c(0, 15), box.ratio=9,
         scales=list(y=list(alternating=0)), 
         border = "transparent", 
         par.settings = list(axis.line = list(col = "transparent")), 
         panel = function(x, y, ...) {
           dots <- list(...)
           br <- dots$box.ratio
           panel.barchart(x, y, ...)
           panel.abline(h = seq_along(x) - 0.5*(br/(br+1)), col="orange", lwd=0.7)
         }
)

enter image description here

+7

All Articles