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

Possible regression in plot.xts titles when using layout #412

Closed
eddelbuettel opened this issue Jan 26, 2024 · 5 comments
Closed

Possible regression in plot.xts titles when using layout #412

eddelbuettel opened this issue Jan 26, 2024 · 5 comments
Milestone

Comments

@eddelbuettel
Copy link
Contributor

Description

We now see the titles 'chopped off' ie clipped ie parts are outside the visible region. That is new, and a regression.

It does not seem to appear on a single plot but when combined via layout() it clearly is an issue.

image

I have a recurrent cronjob plotting (several pages of) three plot a page to pdf where I noticed it first. It is more prevalent for n=3.

Expected behavior

No clipping, ie see the full text.

Minimal, reproducible example

> x11()
> layout(matrix(1:2,2,1,byrow=TRUE), heights=c(1,1,1,1))
> dang::plotOBOS("SPY")          # simple wrapper to plot.xts with a few bells and whistles, old, unchanged
Registered S3 method overwritten by 'dang':
  method    from
  print.xts xts 
> dang::plotOBOS("QQQ")
> 

Session Info

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 23.10

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.11.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Chicago
tzcode source: system (glibc)

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

other attached packages:
[1] RPostgreSQL_0.7-6  DBI_1.2.1          quantmod_0.4.25    TTR_0.24.4         xts_0.13.2        
[6] zoo_1.8-12         data.table_1.14.99

loaded via a namespace (and not attached):
 [1] compiler_4.3.2   tools_4.3.2      parallel_4.3.2   colorout_1.3-0.1 curl_5.2.0      
 [6] grid_4.3.2       dang_0.0.16      jsonlite_1.8.8   lattice_0.22-5   fortunes_1.5-4  
> 
@joshuaulrich
Copy link
Owner

joshuaulrich commented Jan 26, 2024

Thanks for the report! I'll take a look.

Reproducible example below. Note that the header isn't clipped if you make the X11 window larger.

library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)
x11()
layout(matrix(1:2,2,1,byrow=TRUE), heights=c(1,1,1,1))
plot(x[,1], main="Chopped")
plot(x[,1], main="Clipped")

image

@joshuaulrich
Copy link
Owner

This should be fixed on the 412-plot-header-clipped branch. Please test and let me know if you find any issues. Thanks!

@eddelbuettel
Copy link
Contributor Author

Damn straight -- you are correct on the resize. Had not noticed.

So where did behaviour change? In base R? Not so likely? So was this a side-effect from recent cleanup?

@eddelbuettel
Copy link
Contributor Author

Works like a charm off the designated branch, also with a 3x1 layout:

image

@joshuaulrich
Copy link
Owner

So was this a side-effect from recent cleanup?

Yeah, I did a significant refactor of all the plot functionality. It was practically necessary in order to get the log y-axis working.

Works like a charm off the designated branch, also with a 3x1 layout

Awesome, thanks for testing that too!

@joshuaulrich joshuaulrich added this to the Next release milestone Jun 3, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Nov 24, 2024
# xts 0.14.x (202x-xx-xx)

* `plot.xts()` now renders all panels when 'x' has more than 8 columns and
  `multi.panel = TRUE`. Columns 9 and later didn't render because the default
  of `plot.xts()` is 'col = 1:8'. Thanks to Ethan Smith for the report and
  patch.
  ([#423](joshuaulrich/xts#423))
  ([#424](joshuaulrich/xts#424))

* `plot.xts()` no longer errors when 'ylim' is constant and negative. Thanks
  to Ethan Smith for the report.
  ([#422](joshuaulrich/xts#422))

* Do not use `SET_TYPEOF()` in C because it is not part of the public R API.

* `merge.xts()` no longer converts 'x' or 'y' from double to integer in the C
  code when they are not used in the result. This avoids an unnecessary and
  confusing warning. Thanks to Jeff Ryan for the report.

# xts 0.14.0 (2024-06-05)

* `addEventLines()` and `addLegend()` now draw on multiple panels when `on` is
  a vector. Thanks to Ethan Smith for the report.
  ([#420](joshuaulrich/xts#420))

* Replace `SET_TYPEOF()` in merge.c because it will error when it tries to
  convert a REAL to an INTEGER. Thanks to Kurt Hornik for the report!
  ([#419](joshuaulrich/xts#419))

* Fix crash when 'j' is not an integer and in [0, 1) (e.g. `j = 0.1`). Also
  throw a warning when 'j' is not an integer.
  ([#413](joshuaulrich/xts#413))
  ([#415](joshuaulrich/xts#415))

* Fix plot header when `layout()` is used to draw multiple plots on a single
  device. Thanks to Dirk Eddelbuettel for the report and testing!
  ([#412](joshuaulrich/xts#412))

* Fix plot legend location when the y-axis is log scale.
  ([#407](joshuaulrich/xts#407))

# xts 0.13.2 (2024-01-21)

* Print a message when `period.apply()` is called with `FUN = mean` because it
  calculates the mean for each column, not all the data in the subset like it
  does for all other functions. The message says to use `FUN = colMeans` for
  current behavior and `FUN = function(x) mean(x)` to calculate the mean for
  all the data. This information is also included in the help files. The option
  `xts.message.period.apply.mean = FALSE` suppresses the message.
  ([#124](joshuaulrich/xts#124))

* Fix error when `print.xts()` is called 'quote' or 'right' arguments.
  ([#401](joshuaulrich/xts#401))

* Fix `addPolygon()` so it renders when `observation.based = TRUE`.
  ([#403](joshuaulrich/xts#403))

* Print trailing zeros for index value with fractional seconds, so every index
  value has the same number of characters.
  ([#404](joshuaulrich/xts#404))

* Add ability to log scale the y-axis in `plot.xts()`.
  ([#103](joshuaulrich/xts#103))

* Actually change the underlying index values when 'tclass' is changed from a
  class with a timezone (e.g. POSIXct) to one without a timezone (e.g. Date).
  Add a warning when this happens, with a global option to always suppress the
  warning.
  ([#311](joshuaulrich/xts#311)).

* Significantly refactor the internals of `plot.xts()`.
  ([#408](joshuaulrich/xts#408))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants