Reputation: 1809
I'm rendering an RMarkdown document with ggplots to HTML. Unfortunately I'm unable to post a replicable example, but here's the gist of the problem:
The plot looks nice and crisp in the RMarkdown document. It also looks crisp in the default output (when I knit the RMarkdown, an HTML document opens up within R).
When I open the same HTML document in chrome, it looks notably lower-resolution.
Here it is within R, nice and crisp:
Here it is within chrome (blurry):
Same exact HTML document. What gives?
Upvotes: 2
Views: 1191
Reputation: 64
I'd recommend switching to .svg instead of .png
This has some advantages and disadvantages but, for me at least, solves the problem with playing with dimensions of the rendered graphic. Chrome and Edge / Internet Explorer seems to have no problems whatsoever with displaying .svg in htmls I generate from R Markdown and share with collaborators.
Please see here for how to change format: https://bookdown.org/yihui/rmarkdown-cookbook/graphical-device.html
This new package in Tidyverse might be of use too: https://www.tidyverse.org/blog/2021/02/svglite-2-0-0/
Upvotes: 2
Reputation: 4949
Its probably your zoom. Make sure to set the zoom to exactly 100% for both browsers. I had this issue before.
Upvotes: 0
Reputation: 3242
Would you be able to try a solution if you can't replicate the issue? I think this may be solved if you tried
---
output:
html_document:
self_contained: yes
mode: selfcontained
---
Which creates a self contained HTML file by base64 encoding images, which I hope would retain the higher quality image.
Upvotes: 2