Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot.xts doesn't plot more than 8 columns properly on multi.panel = T #423

Closed
ethanbsmith opened this issue Jul 28, 2024 · 2 comments · Fixed by #424
Closed

plot.xts doesn't plot more than 8 columns properly on multi.panel = T #423

ethanbsmith opened this issue Jul 28, 2024 · 2 comments · Fixed by #424
Milestone

Comments

@ethanbsmith
Copy link
Contributor

ethanbsmith commented Jul 28, 2024

Description

when plotting more than 8 columns in multi.panel, the last columns dont display
this is because plot.xts defaults col = 1:8

Expected behavior

default should handle any number of columns properly, either recycling the colors after 8, or defaulting col = 1:ncol(x)

Minimal, reproducible example

This code doesn't plot the lines on the last 2 panels because there's no 'col' value for them by default.

d <- xts(matrix(1:100, ncol = 10), order.by = Sys.Date() + (1:10))
plot(d, multi.panel = T)

image

Session Info

R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Denver
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] xts_0.14.1 zoo_1.8-12

loaded via a namespace (and not attached):
[1] compiler_4.4.0 grid_4.4.0     lattice_0.22-6
@joshuaulrich
Copy link
Owner

This should be straightforward to fix. Want to give it a shot? It might be as easy as setting the default col = 1:nrow(x).

Is it also an issue for a single plot of an object with more than 8 columns?

@ethanbsmith
Copy link
Contributor Author

multi.panel = F looks like it recycles col values.
chart.lines handles recycling via: if(length(col) < NCOL(x)) col <- rep(col, length.out = NCOL(x))

I can work on a pr to move that check earlier in the flow

joshuaulrich pushed a commit that referenced this issue Aug 6, 2024
When 'x' has more than 8 columns and multi.panel = TRUE, columns 9 and
later don't render because of the default 'col = 1:8'. Thanks to Ethan
Smith for the report and patch.

Fixes #423
@joshuaulrich joshuaulrich added this to the 0.14.1 milestone Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants