joshuaulrich / joshuaulrich/quantmod

addTA creates legend (when legend=NULL) when plotting on an existing subchart

Open
#67 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
R
Stars
906
Forks
233
PR merge metrics
No merged PRs in 30d

Description

For example:

``` r
library(quantmod)
data(sample_matrix)
x <- as.xts(sample_matrix)
chartSeries(x, theme=chartTheme("white"))
addTA(Cl(x)*1.01, on=1, legend=NULL) # adds legend even though legend=NULL
addTA(Cl(x), legend=NULL) # no legend (new subplot)
addTA(Op(x), on=2, legend=NULL, col="green") # adds legend
```

![quantmod_issue](https://cloud.githubusercontent.com/assets/1023193/10046526/d173bbe2-61ce-11e5-8340-b04c16e0bd87.png)

The only legend that should be on the above image is "Last 47.76...". The relevant line(s) of code seem to be in the `chartTA` function in `R/TA.R`, specifically:

``` r
if(!x@new) {
legend <- function(legend,text.col,...) {
list(legend=legend,text.col=text.col)
}
}
```

But I'm not sure what needs to change to fix this issue without breaking anything.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproduction using chartSeries and addTA, then inspect chartTA in R/TA.R, especially the !x@new legend handling. Trace how legend=NULL is treated for existing versus new subcharts. Done means the reproduction creates no legend for the calls with legend=NULL while preserving the expected "Last 47.76..." legend.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.