xts icon indicating copy to clipboard operation
xts copied to clipboard

plot.xts - add stacked bar chart.type

Open rossb34 opened this issue 9 years ago • 0 comments

We can get really close to doing stacked/unstacked bar charts by replacing chart.lines within plot.xts with the following:

chart.bars <- function(x, colorset=1:10, ...){
    positives = negatives = x
    for(column in 1:NCOL(x)){
        for(row in 1:NROW(x)){ 
            positives[row,column]=max(0,x[row,column])
            negatives[row,column]=min(0,x[row,column])
        }
    }
    barplot(t(positives), add=TRUE, col=colorset, axisnames = FALSE, axes = FALSE, ...)
    barplot(t(negatives), add=TRUE , col=colorset, axisnames = FALSE, axes = FALSE, ...)
}

It would still need some parameterization to get the geometry correct.

https://github.com/joshuaulrich/xtsExtra/issues/14

rossb34 avatar Apr 11 '15 11:04 rossb34