Had some recent issues with my workflow. I normally print Rplots as .emf files using the devEMF package, and then edit them in powerpoint. [Import the emf file to powerpoint, right click on image, and select ungroup.] However, recently powerpoint isn't recognizing the vector format when I "ungroup."
I'm using a windows machine and powerpoint 2016.
Any thoughts would be VERY helpful.
Nate
Just to leave a definitive answer here -- Powerpoint does not yet allow editing ("ungrouping") of EMF+ graphics. Thus the solution is to tell devEMF to not use emfPlus features (the downside being that features such as transparency will not be available):
emf(file = "test.emf", emfPlus = FALSE)
plot(1:10)
dev.off()
The original poster's comment worked because the older version of devEMF did not use emfPlus by default.
Related
I am trying to convert this example pdf to png using the animation package the same way it´s done here Convert pdf to png in R
library("animation")
ani.options(outdir = "//Usuarios/Facturas")
pdf("Factura.pdf")
plot(1:10)
dev.off()
im.convert("Factura.pdf",
output = "Factura.png")
But I have this error:
Same error than here: Error using magick R to import PDF but that solution makes reference to an external software that I don´t find in the original post (and I haven´t installed). I red that Ghostscript do what I want (pdf to png), but isn´t what animation package suppose to do?
Or I messed up my brain?
Thanks
The animation package uses ImageMagick for some of its features (which is why ImageMagick is listed as a system requirement in the manual). ImageMagick in turn apparently uses Ghostscript for PDF rendering. So yeah: the Ghostscript issues discussed here are certainly worth looking into.
Finally I found the answer with another package, I am gonna explain if someone need it.
library(pdftools)
library(magick)
fichero="Factura.pdf"
png= pdftools::pdf_convert(fichero, dpi = 600)
# And if someone want to read it
png2 = image_read(png)
This doesn´t save any file .png, which is a perfect solution for my situation.
Is there any way out here?
Evince is the standard PDF viewer of Ubuntu. The immensely popular platform for statistics, R, started its life as a Linux package. But when I do a plot in R -- vanilla, no frills, no user options -- and save it to PDF, I can never see axis labels, titles etc. In evince, even though they appear in every possible viewer (Acrobat, Foxreader, Sumatra, qpdfview) on any OS. I have included qpdfview as default in memeapps.list, but when I double-click a PDF file, I get evince. Is there any help except uninstall evince (which I don't want to do as it helps with other file formats).
I created several simple ggplot2 plots and saved them to PDF files using the following commands:
p <- ggplot(plotobject, aes(x=Pos, y=Pval),res=300)
ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf")
If I now open this example.pdf in Adobe Illustrator I get the following error:
The font AdobePiStd is missing. Affected text will be displayed using
a substitute font.
Is there a way in ggplot2 to specify a font (I presume this is for the dots/points) that Adobe will understand or otherwise is there a way to get this font working in Adobe?
/edit just to clarify, the text/labels/titles are all just fine its the dots that are missing for the font
/edit2 I got a working solution by just using the EPS output in ggsave, but still would love to find out a way to also be able to just open/import ggplot2 plots in PDF format directly in AI
Although changing the fonts used by AI works well, an alternative is to restrict ggplot2 from using Dingbats in the first place by adding the argument 'useDingbats' to your ggsave command eg:
ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf", useDingbats=FALSE)
I ran into this problem as well on Mac OS X 10.8.2.
This resolved the issue for me:
font='/Library/Application Support/Adobe/PDFL/10.9/Fonts/AdobePiStd.otf'
cp $font /Library/Fonts/
On your system, find the file with find:
find / -name AdobePiStd.otf 2>/dev/null
/Applications/Adobe Photoshop CC 2018/Adobe Photoshop CC 2018.app/Contents/Required/PDFL/Resource/Fonts/AdobePiStd.otf
/Applications/Adobe Illustrator CC 2018/Adobe Illustrator.app/Contents/Required/PDFL Resource/Resource/Fonts/AdobePiStd.otf
/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Resources/Resource/Font/AdobePiStd.otf
For dots or points that don't' display correctly in a pdf, I just substitute Zapf Dingbats for the missing font in Adobe Illustrator. For simple plot markers, this does the job most of the time.
This seems to be a perverse problem in which Adobe Illustrator cannot find a font (AdobePiStd) that is distributed with Adobe Reader and thus is likely present.
If you search your computer, you are likely to find it. On my WindowsXP system, it was in:
C:\Program Files\Adobe\Reader 10.0\Resource\Font
After finding it, you can install it and other fonts in that folder, which should enable Illustrator to find them.
For other font/pdf problems in R, the embedFonts function in grDevices package is useful.
Use useDingbats=FALSE for the pdf output, then Illustrator will no complain.
pdf("example.pdf", useDingbats=FALSE)
ggplot(plotobject, aes(x=Pos, y=Pval),res=300)
dev.off()
You can download the font AdobePiStd - just Google it, download and install. After you reboot, the font should display correctly. You can then use the 'Find Font ...' utility within Illustrator to change it if you wish.
EDIT 2018 The question under was for the initial confusion face. The answer to this question is pdf(useDingbats = FALSE) as stated in numerous answers above. I won't delete this answer, in case you want to read about fonts (which might become a problem too).
OLD ANSWER AI does not recognize Helvetica type fonts. In my computer it doesn't matter that much, since it automatically replaces the font with something suitable. Of course you'd want to change the font in some cases. I often do it manually in AI (just select all the text and change the font type). Here is a thread on how to change the font in ggplot2: Modifying fonts in ggplot2
Ps. There is also another thread that might be helpful: Fonts in R plots
Another option that in simple cases might solve the problem is to in illustrator select the textobjects not displayed correctly and change the font. Helvetica Neue works for me.
I could solve the problem just by adding alpha specification. If you don't need any transparency you can chose an alpha value of 0.9 ...
example:
ggplot() + geom_point(aes(x=..,y=.., color=...), alpha=0.8)
RStudio has a wonderful set of skeletons for packages and Rmd documents. But, I'd like to know if it's possible to change the defaults to a "skeleton" of your own design. If, like me, you package your research for yourself/clients, you quickly find yourself deleting and copying the same work over and over.
I suppose there are two related questions here:
Can you change the default package skeleton?
Can you change the default Rmd skeleton?
There is no supported way to do this. However, the skeletons are stored as ordinary files in your filesystem, so there's nothing stopping you from modifying them. For instance, if you're on the Mac, this file provides the default Rmd skeleton:
/Applications/RStudio.app/Contents/Resources/resources/templates/r_markdown_v2.Rmd
On Windows, it's here:
C:\Program Files\RStudio\resources\templates\r_markdown_v2.Rmd
I didn't realize it then, but I was actually looking for a custom format. The details of which are documented extensively on the rmarkdown rstudio site.
http://rmarkdown.rstudio.com/developer_custom_formats.html
I've just started using Sweave on TeXShop ( which runs on OSX). Is it possible to have syntax coloring of the source code so that I can distinguish between raw text and R-code?
For example, the following code snippet in my Sweave file is the same as the rest of the text, which makes it harder to read than an R editor that has syntax coloring.
<<reg, fig=TRUE, echo=FALSE>>=
a = c(10,15)
plot(a, a)
#
(I have also tried this out using the wonderful RStudio which does have syntax coloring for both R and Latex, but I think TexShop is superior for LaTeX.)
I don't believe TexShop supports mode switching (e.g. highlighting in two different languages--R and LaTeX--within the same file), since it was designed around a single language (LaTeX). Editors that do and therefore properly handle Sweave are to my knowledge:
Eclipse with Stat/ET
RStudio
Emacs with ESS
Actually, you can use highlighted syntax out of the box. Use pgfSweave package. Just add pgf=TRUE (and echo=TRUE) to your Sweave chunk, and you're good to go. Install pgfSweave, and load a package vignette (vignette("pgfSweave")) for further assistance.
Version 1.1.0 of pgfSweave introduced
the highlight option. The default is
TRUE by default so code will be
syntax-highlighted with the highlight
package.