R loses information when saving the plot as an encapsulated postscript (.eps)

Lyx and Latex work well with .eps images. But when I export a scatter plot with a smoothing curve from Rstudio, the points are lost and the plot is delivered only with the curve.

The two save methods I tried:

  • In Rstudio, select "Export" from the drop-down menu in the image field and save as .eps. Interestingly, in the preview of Rstudio, this plot appears as it should.

  • Imagine the graph code with setEPS()followed by postscript(), with the required dimensions, etc., followed by a call to the graph using library(ggplot2), for example. ggplot().

At first I thought the problem could be elsewhere. But then I saved .eps to Mathematica, and there were no problems.

I looked on the Internet and found other problems with saving .eps to R, but no one was dealing with lost information.

What exactly is going on?

I should mention that rendering .eps images in Lyx is better than any other format, so I insist on using .eps.

Thank you very much in advance for your contribution, I can not vote on it yet.

EDIT

As far as I can tell, this issue was a dead end due to the fact that EPS was not able to save transparent tapes. (See Comments.) Upon request, I posted code that emphasizes the problem.

Say you have data data <- data.frame(replicate(2,rnorm(1000))). You want to build them, but there are so many, so you add a transparency option. In addition, you add a built-in line with a confidence interval. Your code:

ggplot(data = data, aes(x=X1, y=X2)) +
    geom_point(alpha=0.4) +
    stat_smooth(se=T, method="lm")

. EPS, , , , - , .

- EPS, . alpha=1 ( ) se=FALSE.

+5
2

, EPS .

PDF, :

ggplot(data = data, aes(x=X1, y=X2)) +
  geom_point(alpha=0.4) +
  stat_smooth(se=T, method="lm")
dev.copy2pdf(file="plot.pdf",out.type="cairo", width=10, height=7.5)

PDF , EPS pdftops, Inkscape Adobe Illustrator.

PNG , , , ...

Powerpoint, export ( ReporteRs), :

library(export)
library(ggplot2)
data=data.frame(replicate(2,rnorm(1000)))
ggplot(data = data, aes(x=X1, y=X2)) +
  geom_point(alpha=0.4) +
  stat_smooth(se=T, method="lm")
graph2ppt(file="plot.pptx", width=8, height=6)

enter image description here

: EPS, , cairo_ps(), , . cairo_ps() fallback_resolution , ( ). , :

cairo_ps(file = "test.eps", onefile = FALSE, fallback_resolution = 600)
qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width, alpha = I(0.7))
dev.off()

, export:

graph2eps(file="plot.pptx", width=8, height=6, cairo=TRUE, fallback_resolution=600)
+11

, , , - -1 , . select, , / . , R , eps...

+2

All Articles