-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use devEMF::emf instead of grDevices::win.metafile for .wmf/.emf #4541
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
Comments
We already use ragg for high-quality image output, so the idea of using another external package for the same purpose can be acceptable itself. However, I think the question is whether ggplot2 supports .emf/.wmf format that eagerly. Honestly, while I used R on Windows for 5 years, I've never heard of the format until #4521. I'm not totally against your idea, but, considering no maintainer uses Windows actively, I'm afraid it's virtually impossible to maintain the feature reliably (as you already notice .emf/.wmf-related features are broken twice recently: #4521 and #4539). @thomasp85 @clauswilke |
EMF is basically the only vector format that works reliably in Microsoft Word on either Windows or Mac--SVG and PDF support are very buggy |
@yutannihilation: I think we should fix any bugs that prevent people from using the graphics device of their choice, but otherwise I'd be wary of adding dependencies to relatively obscure external packages. Also note that users would likely not have devEMF installed unless they already know about it, so out of the box ggplot2 would basically never use this functionality in practice. @bwiernik Please be aware that another way to fix this issue is for |
My point with this issue is that the default behavior with ggsave when the file extension is wmf or emf is pretty unusable |
I agree with you. I basically believe it should be fixed on grDevices's side if it's grDevices's problem. |
This is really an issue that should be fixed in grDevices... however I'm pretty sure it never will be unless @pmur002 has a very strong urge to dive into that arcane code base :-) I am very much against adding a dependency to a compiled packages that is not developed in public by a developer we have no knowledge of - even as a weak dependency. So any fix will need to find a third route |
I think the best fix would be to ask Microsoft to finally add proper support for SVG in Word 😄 |
I have committed a change to r-devel (r81221) so that the user can specify |
Currently,
ggsave()
uses thegrDevices::win.metafil()
device for output to .wmf/.emf. This device doesn't seem to work very well—when I use it, the actual plot is rendered at half the size of the canvas in the upper left corner. Like this:The
devEMF::emf()
device seems to work much better:I think it would be better to render wmf/emf files using the devEMF device. It would add a dependency (perhaps in Suggests with a warning or error to prompt installation?), but would be worth it for much better emf generation. If that would be acceptable, I can make a PR.
Example emf files for the two devices are attached.
emf_output.zip
Reprex:
Created on 2021-07-03 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: