Quantcast
Channel: グラフ - 廿TT
Viewing all articles
Browse latest Browse all 123

棒グラフをとにかくいっぱい並べて書きたい

$
0
0

f:id:abrahamcow:20200228222814p:plain

set.seed(2)
y <- lapply(1:7, rexp, n=26)
names(y)<- sapply(1:7,function(x)paste0(sample(LETTERS,10),collapse =""))
tab <-list(y=y,x=LETTERS)
class(tab)<-"minibarTable"

plot.minibarTable <-function(tab,...){
  oldpar <- graphics::par(no.readonly =TRUE)
  N <- length(tab$y)
  graphics::par(mar = c(4,10,0,2), oma = rep(1,4))
  graphics::layout(mat =matrix(1:N), respect =FALSE)for(i in1:N){
    tmpy <- tab$y[[i]]
    graphics::plot.default(1:length(tmpy),tmpy,
                           ylim = c(0,max(tmpy)),
                           type ="h",
                           xaxt="n", yaxt="n",
                           xlab ="", ylab ="", 
                           frame.plot =FALSE, ...)
    graphics::abline(h=0)
    graphics::points(1:length(tmpy),tmpy, pch =16, cex =0.9)
    ran <-c(0,max(tmpy))
    graphics::axis(side=4,at=format(ran,digits =2),las=2)
    graphics::mtext(names(tab$y[i]),side=2,las=2)}
  graphics::axis(side=1,at=1:length(tmpy),labels = tab$x,lwd=0)
  graphics::par(oldpar)}

plot(tab)

Viewing all articles
Browse latest Browse all 123

Trending Articles