R复制到inkscape 0.92

时间:2017-06-12 22:40:31

标签: r plot copy-paste inkscape metafile

我是使用R的新手。我的朋友通常使用inkscape来完成他们的R情节。他们使用RStudio和Inkscape v0.92,他们在RStudio中创建了图表

Option Explicit


Sub foo()
  Dim data(6)
  Dim Xupper
  Dim Xlower
  Dim Yupper
  Dim Ylower
  Dim x
  Dim y

  data(0) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[1048574]C[-18]=RC[-18],COUNTIF(RC[-9]:R[1048574]C[-9],0)=0),AVERAGE(RC[-9]:R[1048574]C[-9]),0)", "=IF(AND(R[1048574]C[-19]=RC[-19], COUNTIF(RC[-9]:R[1048574]C[-9],0)=0),AVERAGE(RC[-9]:R[1048574]C[-9]),0)", "=IF(AND(R[1048574]C[-20]=RC[-20],COUNTIF(RC[-9]:R[1048574]C[-9],0)=0),AVERAGE(RC[-9]:R[1048574]C[-9]),0)", "=IF(AND(R[1048571]C[-21]=RC[-21],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-22]=RC[-22],COUNTIF(RC[6]:R[1048571]C[6],0)=0),AVERAGE(RC[6]:R[1048571]C[6]),0)", "=IF(R[1048571]C[-23]=RC[-23],AVERAGE(RC[6]:R[1048571]C[6]),0)", "=(INTERCEPT(RC[-11]:R[5]C[-11],RC[-15]:R[5]C[-15])+(RC[-15]*SLOPE(RC[-11]:R[5]C[-11],RC[-15]:R[5]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")
  data(1) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[-2]C[-18]=RC[-18],COUNTIF(R[-2]C[-9]:RC[-9],0)=0),AVERAGE(R[-2]C[-9]:RC[-9]),0)", "=IF(R[-2]C[-19]=RC[-19],AVERAGE(R[-2]C[-9]:RC[-9]),0)", "=IF(AND(R[-2]C[-20]=RC[-20],COUNTIF(R[-2]C[-9]:RC[-9],0)=0),AVERAGE(R[-2]C[-9]:RC[-9]),0)", "=IF(AND(R[1048571]C[-21]=RC[-21],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[-1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-22]=RC[-22],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-23]=RC[-23],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=(INTERCEPT(R[-1]C[-11]:R[4]C[-11],R[-1]C[-15]:R[4]C[-15])+(RC[-15]*SLOPE(R[-1]C[-11]:R[4]C[-11],R[-1]C[-15]:R[4]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")
  data(2) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[-2]C[-18]=RC[-18],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(R[-2]C[-19]=RC[-19],AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-2]C[-20]=RC[-20],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[1048571]C[-21]=RC[-21],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[-1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-22]=RC[-22],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-23]=RC[-23],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=(INTERCEPT(R[-2]C[-11]:R[3]C[-11],R[-2]C[-15]:R[3]C[-15])+(RC[-15]*SLOPE(R[-2]C[-11]:R[3]C[-11],R[-2]C[-15]:R[3]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")
  data(3) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[-2]C[-18]=RC[-18],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(R[-2]C[-19]=RC[-19],AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-2]C[-20]=RC[-20],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[1048571]C[-21]=RC[-21],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[-1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-22]=RC[-22],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=IF(AND(R[1048571]C[-23]=RC[-23],COUNTIF(RC[-6]:R[1048571]C[-6],0)=0),AVERAGE(RC[-6]:R[1048571]C[-6]),0)", "=(INTERCEPT(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])+(RC[-15]*SLOPE(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")
  data(4) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[-2]C[-18]=RC[-18],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(R[-2]C[-19]=RC[-19],AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-2]C[-20]=RC[-20],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-5]C[-21]=RC[-21],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=IF(AND(R[-5]C[-22]=RC[-22],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=IF(AND(R[-5]C[-23]=RC[-23],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=(INTERCEPT(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])+(RC[-15]*SLOPE(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")
  data(5) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[-2]C[-18]=RC[-18],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(R[-2]C[-19]=RC[-19],AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-2]C[-20]=RC[-20],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-5]C[-21]=RC[-21],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=IF(AND(R[-5]C[-22]=RC[-22],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=IF(AND(R[-5]C[-23]=RC[-23],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=(INTERCEPT(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])+(RC[-15]*SLOPE(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")
  data(6) = Array("=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]/DAY(EOMONTH(RC[-2],0))", "=RC[-2]", "=RC[-3]+RC[-2]/6", "=RC[-4]+RC[-3]/14", "=IF(AND(R[-2]C[-18]=RC[-18],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(R[-2]C[-19]=RC[-19],AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-2]C[-20]=RC[-20],COUNTIF(R[-2]C[-3]:RC[-3],0)=0),AVERAGE(R[-2]C[-3]:RC[-3]),0)", "=IF(AND(R[-5]C[-21]=RC[-21],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=IF(AND(R[-5]C[-22]=RC[-22],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=IF(AND(R[-5]C[-23]=RC[-23],COUNTIF(R[-5]C[-6]:RC[-6],0)=0),AVERAGE(R[-5]C[-6]:RC[-6]),0)", "=(INTERCEPT(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])+(RC[-15]*SLOPE(R[-3]C[-11]:R[2]C[-11],R[-3]C[-15]:R[2]C[-15])))-RC[-11]", "=IF(RC[-11]=0,0,IF(RC[-1]>RC[-11],0,1))", "=IF(RC[-1]=1,RC[-11],0)", "=0", "=0")

  Xlower = LBound(data(0))
  Ylower = LBound(data)

  Xupper = UBound(data(0)) '15
  Yupper = UBound(data) '6
  ReDim tempdata(Xupper, Yupper)

  For x = Xlower To Xupper
      For y = Ylower To Yupper
          tempdata(x, y) = data(y)(x)
      Next y
  Next x
End Sub

然后只需在inkscape中Export > Copy to Clipboard > Copy as Metafile > Copy Plot 。但是当我这样做时,inkscape中粘贴的情节就会完全被破坏。

我的例子:

在RStudio中

Ctrl + V

Image Here

然后,当我在inkscape中data=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25) par(pty="s") qqnorm(data, pch=19, cex = 0.8, xlab = "Quantis Teóricos", ylab= "Amostra", las=1, main="Gráfico QQ", lwd = 0.25, cex.main=1.0, cex.lab=0.75, cex.axis=0.75, font.lab=2, xlim=c(-5,5), xaxs="r", yaxs="r") qqline(data, lwd = 0.25) grid(4, 5, lwd = 0.25) box(lwd = 0.25) 时,我得到了

a little zoom

任何人都知道如何解决它???

1 个答案:

答案 0 :(得分:2)

参考此link;

您不应该复制/粘贴到inkspace中,而是输出*.svg以便稍后在该环境中对其进行编辑。

mypath <- "Path/to/the/desired/folder/myplot.svg" #Edit the path as you wish
svg(mypath, width = 8, height = 10)

data=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25) 
par(pty="s")
qqnorm(data, pch=19, cex = 0.8, xlab = "Quantis Teóricos", ylab= "Amostra", las=1, 
    main="Gráfico QQ", lwd = 0.25, cex.main=1.0, cex.lab=0.75, cex.axis=0.75,
   font.lab=2, xlim=c(-5,5), xaxs="r", yaxs="r")
 qqline(data, lwd = 0.25)
 grid(4, 5, lwd = 0.25)
 box(lwd = 0.25)

dev.off()

这将为您提供一个以后可以在Inkspace中编辑的文件。