xts
xts copied to clipboard
plot.xts - bar chart type
Although line type='h'
gives a vertical line that can pass as a bar when there's enough data, sometimes you need a barplot
style rectangle instead.
The closest example is PerformanceAnalytics::chart.StackedBar
. It uses barplot
internally, and aligns that plot with axTicksByTime
.
It's not exactly clear how the behavior should work. It might need to act almost exactly like chart.StackedBar.xts
if there are multiple columns passed into a single plot (and positive and negative values need to be plotted separately). If each line gets it's own panel, it's much simpler.
This might be a more generally useful comment, but Peter Carl has had good luck using pretty
with barplot
, specifically for the y-axis. For example, the code below gives a much better result than without it, keeping the data from being compressed to the edge of the plot area. That might be true for lines as well.
bp <- barplot(momentum, las=1, horiz=TRUE, axes=FALSE,
names.arg=names.arg, xlim = range(pretty(momentum)), ...=...)
axis(1, at=pretty(momentum))
https://github.com/joshuaulrich/xtsExtra/issues/4