joshuaulrich/xtsExtra

[R-Forge #5865] plot2.xts - add legend to plot interior or as a separate panel

Closed this issue · 1 comments

Submitted by: Peter Carl
Assigned to: Nobody
R-Forge link

Actually, legend works reasonably well as is when parameterized by hand:

plot2_xts(R)
legend('bottomright', legend=colnames(R), col=1:4, lwd=4, cex=.6, inset=.05)

It could, however, be smarter and easier to apply. By smarter, it would be aware of the geometry of the interior plot and wouldn't overplot the yaxis, e.g.:

legend('bottomleft', legend=colnames(R), col=1:4, lwd=4, cex=.6)

In addition, it would pick up on the theme applied such that col and cex would be consistent with the rest of the plot, automatically (with col=colorset in the theme). It would also pick up on the column names from the data, if they weren't passed in.

In addition, it could be wrapped into a panel by itself, for example placed between two panels with data:

plot2_xts(R, FUN='CumReturns', panels=c('addLegend('center', lwd=4)', 'addDrawdowns()'))

Followups:

Date: 2014-09-01 16:32
Sender: Ross Bennett
see commit r843

fixed in commit r843