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

svglite does not play nice with xts #126

Closed
paessens opened this issue Dec 15, 2020 · 26 comments
Closed

svglite does not play nice with xts #126

paessens opened this issue Dec 15, 2020 · 26 comments

Comments

@paessens
Copy link

Hi dear Developers,
there seems to be a bug in svglite, hence, we cannot use the compiled svg-image without correction.

test case: [see test-svglite.R, files attached]

  • import times series as xts
  • specify filename (*.svg)
  • plot, i.e. plot.xts
  • first file is test2.svg and this cannot be opened in a viewer
  • firefox shows error
    Image 15 12 20 at 17 55

Solution: the first 11 lines must be deleted!

Untitled 2

corrected svg

Please could you investigate and remediate?
Many thanks and much appreciated.

Heinrich

Archive.zip

@paessens paessens reopened this Dec 15, 2020
@paessens
Copy link
Author

heck ... I forgot ...
Untitled 3

@paessens paessens reopened this Dec 15, 2020
@thomasp85
Copy link
Member

This seems to be based on the CRAN version of svglite... The dev version includes a lot of rewrites, so can you check if the issue persists there?

@paessens
Copy link
Author

paessens commented Feb 1, 2021

yes, it's still there
Screenshot 2021-02-01 at 13.24.26.pdf

My function for a corrected svg-file is

Screenshot 2021-02-01 at 13.25.40.pdf

@paessens
Copy link
Author

paessens commented Feb 1, 2021

then I have a corrected svg like this

file2b551127afa2.svg.zip

@paessens
Copy link
Author

paessens commented Feb 1, 2021

sorry, I did this not in test

prod-env-Rstudio

@thomasp85
Copy link
Member

According to that you are still using the CRAN version of svglite?

@paessens
Copy link
Author

paessens commented Feb 1, 2021

well, this happened. which version is it?

Untitled 2

@thomasp85
Copy link
Member

You'll need to restart R to have the update take effect

@thomasp85
Copy link
Member

Also, if it does persist please provide a reproducible example

@paessens
Copy link
Author

paessens commented Feb 1, 2021

OK, in test, I take the files from above Archive.zip

The CRAN version delivers file, but needs correction, as shown above.
The github version fails to write the file as requested by svglite('test2.svg') in the first step.

Untitled 3

@thomasp85
Copy link
Member

I cannot replicate this. Neither the error message nor any problems with the generated svg... Do you have write access to the location you are working in?

@paessens
Copy link
Author

paessens commented Feb 1, 2021

Yes i do

@thomasp85
Copy link
Member

Is xts required to trigger the issue?

@paessens
Copy link
Author

paessens commented Feb 1, 2021

Yes, no issues with other data types crossed my path so far. I value svg and especially svglite very much since the file sizes can be kept small. That's also the reason why I use svg-buddy to optimize (even more). To keep typography consistent my preferred font (roboto condensed) is embedded, but only once for the dashboard (of 20 or more svg files).

@thomasp85
Copy link
Member

Is there anything weird about your setup at all? Since I can't replicate any of this and since a graphic device have no concept of which packages are loaded (it only receives low-level instructions such as "draw a line there") this issue seems downright unsolvable unless we can somehow replicate it outside of your computer

@paessens
Copy link
Author

paessens commented Feb 2, 2021

Not that I know, everythng is fine considering setup on debian10 and macos11.15.7, on both machines the issue arises as you can see above. Let me check this issue on windows later the day.

@paessens
Copy link
Author

paessens commented Feb 3, 2021

here is testing windows -- same result, i.e. theres two def-tagged sections before the xml and svg tag that should not be there (the same applis to CRAN version)

Screenshot 2021-02-03 at 03 34 52

@paessens
Copy link
Author

paessens commented Feb 3, 2021

here is the corrected svg file

Screenshot 2021-02-03 at 03 45 49

@thomasp85
Copy link
Member

Can you provide a reprex that does not rely on any loaded data

@paessens
Copy link
Author

paessens commented Feb 3, 2021

here you go -- same issue

Screenshot 2021-02-03 at 10 07 39

@paessens
Copy link
Author

paessens commented Feb 3, 2021

Screenshot 2021-02-03 at 10 14 26

@thomasp85
Copy link
Member

Please use the reprex package as it ensures that your example is self contained and is not reliant on anything in your R setup. Have a look at https://reprex.tidyverse.org/index.html to familiarise yourself with the package

@paessens
Copy link
Author

paessens commented Feb 3, 2021

Sorry Thomas, I can't see any benefit from that. I consider the provided examples as simple, reproducible and self contained. The produced image should look like

Screenshot 2021-02-03 at 10 20 30

and not like

Screenshot 2021-02-03 at 10 28 12

@thomasp85
Copy link
Member

I can see your issue now... In the future though, please do not use screen shots of code as it makes it extremely cumbersome for those you wish to help you reproduce your issue

@paessens
Copy link
Author

paessens commented Feb 3, 2021

here you go:

require(xts)
require(svglite)
sessionInfo()
# estr <- readRDS("estr.rds")
estr <- xts(1:10, Sys.Date()+1:10)
svglite('test2.svg')
plot(estr, main='€STR')
dev.off()

@paessens
Copy link
Author

paessens commented Feb 3, 2021

sorry I should know what a hashtag means in MD ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants