EPS形式の出力
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
// 谷村晋
// 自由に加筆をお願いします。
COLOR(green){SIZE(25){EPS形式の出力}}
ここではグラフィックウィンドウに描画されているグラフを EP...
#contents
#comment
* EPS形式の出力コマンド [#zfb2be64]
> dev.copy2eps(file="ファイル名.eps")
表示されているグラフィックが EPSF 形式で保存されます。dev...
> dev.copy(device=postscript,file="ファイル名.eps", onef...
と同じことをしている。いちいちオプションを指定するのは面...
* 出力サイズ指定 [#h2c110de]
> dev.copy2eps(file="ファイル名.eps",width=数値,height=...
幅や高さを指定できる。幅と高さのどちらか一方のみを指定す...
''例'' 横幅を4インチにする場合
> dev.copy2eps(file="width-test.eps",width=4)
* フォント指定 [#abe46caf]
> dev.copy2eps(file="ファイル名.eps",family="フォント名")
** 指定できるフォント(オリジナル版R) [#laa3b60c]
| 標準ポストスクリプトフォント | AvantGarde |
|~| Bookman |
|~| Courier |
|~| Helvetica |
|~| Helvetica-Narrow |
|~| NewCenturySchoolbook |
|~| Palatino |
|~| Times |
| URWフォント | URWGothic |
|~| URWBookman |
|~| NimbusMon |
|~| NimbusSan |
|~| NimbusSanCond |
|~| CenturySch |
|~| URWPalladio |
|~| NimbusRom |
| その他 | ComputerModern |
// - ポストスクリプトフォント(AvantGarde, Bookman, Couri...
// - URWフォント(URWGothic, URWBookman, NimbusMon, Nimbu...
// - その他(ComputerModern)
** 表示例 [#z18e9114]
epsfont <- function(x) {
plot(0:2,0:2,type="n",axes=FALSE,xlab="",ylab="")
text(0,1.9,x,cex=5,font=1,pos=4) #標準
text(0,1.6,x,cex=5,font=2,pos=4) #太字
text(0,1.3,x,cex=5,font=3,pos=4) #斜体
text(0,1,x,cex=5,font=4,pos=4) #太字斜体
text(0,0.7,"0123456789",cex=3,pos=4)
dev.copy2eps(file=paste(x,".eps",sep=''),family=x)
system(paste("convert -trim ",x,".eps ",x,".png",sep='...
}
このepsfont()を使って表示してみる。
*** AvantGarde [#g6adbafb]
> epsfont("AvantGarde")
#ref(AvantGarde.png,center)
*** Bookman [#x0a35f00]
> epsfont("Bookman")
#ref(Bookman.png,center)
*** Courier [#i2b44c79]
> epsfont("Courier")
#ref(Courier.png,center)
*** Helvetica [#d9dc3786]
familyを無指定の時に適用されるデフォルトのフォント
> epsfont("Helvetica")
#ref(Helvetica.png,center)
*** Helvetica-Narrow [#o16f21a6]
> epsfont("Helvetica-Narrow")
#ref(Helvetica-Narrow.png,center)
*** NewCenturySchoolbook [#f2a2657f]
> epsfont("NewCenturySchoolbook")
#ref(NewCenturySchoolbook.png,center)
*** Palatino [#r97a14c8]
> epsfont("Palatino")
#ref(Palatino.png,center)
*** Times [#add19e1d]
> epsfont("Times")
#ref(Times.png,center)
*** URWGothic [#a7a40e88]
> epsfont("URWGothic")
#ref("URWGothic.png",center)
*** URWBookman [#ofa68c25]
> epsfont("URWBookman")
#ref("URWBookman.png",center)
*** NimbusMon [#l6de88b7]
> epsfont("NimbusMon")
#ref("NimbusMon.png",center)
*** NimbusSan [#d0695586]
> epsfont("NimbusSan")
#ref("NimbusSan.png",center)
*** NimbusSanCond [#cc1121cc]
> epsfont("NimbusSanCond")
#ref("NimbusSanCond.png",center)
*** CenturySch [#p67baca2]
> epsfont("CenturySch")
#ref("CenturySch.png",center)
*** URWPalladio [#bf41bca4]
> epsfont("URWPalladio")
#ref("URWPalladio.png",center)
*** NimbusRom [#ve8b4b0b]
> epsfont("NimbusRom")
#ref("NimbusRom.png",center)
*** ComputerModern [#u2cb3246]
> epsfont("ComputerModern")
#ref("ComputerModern.png",center)
* pointsizeの指定 [#w1107c99]
点の大きさを指定できる
** pointsizeの指定例 [#eaebf640]
#ref(pointsize.png,center)
何故だがpointsizeを大きくすると描画領域が小さくなる。
* titleの指定 [#x62d8898]
これはグラフィックのmainオプションとは異なり、EPSファイル...
> dev.copy2eps(title="ADIS mortality in Honduras")
として、出力されたEPSファイルの中を見ると
%!PS-Adobe-3.0 EPSF-3.0
%%DocumentNeededResources: font Helvetica
%%+ font Helvetica-Bold
%%+ font Helvetica-Oblique
%%+ font Helvetica-BoldOblique
%%+ font Symbol
%%Title: ADIS mortality in Honduras
%%Creator: R Software
%%Pages: (atend)
%%BoundingBox: 0 0 268 263
%%EndComments
となっている。
* カラーのグラフィックをグレー階調のepsにする [#r1ffdbfd]
簡単にグレー階調になってくれないグラフィック関数を使って...
カラーのepsをグレー階調にする[[bw_convert:http://www-herm...
> pie(c(2,10,3),c("S","R","S-plus"))
> dev.copy2eps(file="カラー.eps")
> dev.copy2eps(file="| sed -e 's/\bsetrgbcolor\b/add add...
&ref("color-pie.png"); &ref("gray-pie.png");
また、ImageMagickのconvertを使う方法もあります。
> dev.copy2eps(file="| convert -type Grayscale - グレー...
Rによるeps出力は、フォントを埋め込まずベクター形式で、大...
* 暗色のスライド用に色を変更する [#e11bd97b]
プレゼンテーション用に色を反転させたグラフィックも同時に...
ここでは、昔懐かしいブルースライドにしてみます。
> par(bg='white') #背景色設定をepsに入れないと、そもそ...
> pie(c(2,10,3),c("S","R","S-plus"))
> dev.copy2eps(file="カラー.eps")
> blue.slide <- paste("| sed -e 's/\\bsetrgbcolor\\b/po...
+ "-e 's/\\b1 setgray\\b/0 0 0.6 setrgbcolor/g'",
+ "-e 's/\\b0 setgray\\b/1 setgray/g' > スライド.eps"...
> dev.copy2eps(file=blue.slide)
&ref("color-pie.png"); &ref("blue-pie.png");
終了行:
// 谷村晋
// 自由に加筆をお願いします。
COLOR(green){SIZE(25){EPS形式の出力}}
ここではグラフィックウィンドウに描画されているグラフを EP...
#contents
#comment
* EPS形式の出力コマンド [#zfb2be64]
> dev.copy2eps(file="ファイル名.eps")
表示されているグラフィックが EPSF 形式で保存されます。dev...
> dev.copy(device=postscript,file="ファイル名.eps", onef...
と同じことをしている。いちいちオプションを指定するのは面...
* 出力サイズ指定 [#h2c110de]
> dev.copy2eps(file="ファイル名.eps",width=数値,height=...
幅や高さを指定できる。幅と高さのどちらか一方のみを指定す...
''例'' 横幅を4インチにする場合
> dev.copy2eps(file="width-test.eps",width=4)
* フォント指定 [#abe46caf]
> dev.copy2eps(file="ファイル名.eps",family="フォント名")
** 指定できるフォント(オリジナル版R) [#laa3b60c]
| 標準ポストスクリプトフォント | AvantGarde |
|~| Bookman |
|~| Courier |
|~| Helvetica |
|~| Helvetica-Narrow |
|~| NewCenturySchoolbook |
|~| Palatino |
|~| Times |
| URWフォント | URWGothic |
|~| URWBookman |
|~| NimbusMon |
|~| NimbusSan |
|~| NimbusSanCond |
|~| CenturySch |
|~| URWPalladio |
|~| NimbusRom |
| その他 | ComputerModern |
// - ポストスクリプトフォント(AvantGarde, Bookman, Couri...
// - URWフォント(URWGothic, URWBookman, NimbusMon, Nimbu...
// - その他(ComputerModern)
** 表示例 [#z18e9114]
epsfont <- function(x) {
plot(0:2,0:2,type="n",axes=FALSE,xlab="",ylab="")
text(0,1.9,x,cex=5,font=1,pos=4) #標準
text(0,1.6,x,cex=5,font=2,pos=4) #太字
text(0,1.3,x,cex=5,font=3,pos=4) #斜体
text(0,1,x,cex=5,font=4,pos=4) #太字斜体
text(0,0.7,"0123456789",cex=3,pos=4)
dev.copy2eps(file=paste(x,".eps",sep=''),family=x)
system(paste("convert -trim ",x,".eps ",x,".png",sep='...
}
このepsfont()を使って表示してみる。
*** AvantGarde [#g6adbafb]
> epsfont("AvantGarde")
#ref(AvantGarde.png,center)
*** Bookman [#x0a35f00]
> epsfont("Bookman")
#ref(Bookman.png,center)
*** Courier [#i2b44c79]
> epsfont("Courier")
#ref(Courier.png,center)
*** Helvetica [#d9dc3786]
familyを無指定の時に適用されるデフォルトのフォント
> epsfont("Helvetica")
#ref(Helvetica.png,center)
*** Helvetica-Narrow [#o16f21a6]
> epsfont("Helvetica-Narrow")
#ref(Helvetica-Narrow.png,center)
*** NewCenturySchoolbook [#f2a2657f]
> epsfont("NewCenturySchoolbook")
#ref(NewCenturySchoolbook.png,center)
*** Palatino [#r97a14c8]
> epsfont("Palatino")
#ref(Palatino.png,center)
*** Times [#add19e1d]
> epsfont("Times")
#ref(Times.png,center)
*** URWGothic [#a7a40e88]
> epsfont("URWGothic")
#ref("URWGothic.png",center)
*** URWBookman [#ofa68c25]
> epsfont("URWBookman")
#ref("URWBookman.png",center)
*** NimbusMon [#l6de88b7]
> epsfont("NimbusMon")
#ref("NimbusMon.png",center)
*** NimbusSan [#d0695586]
> epsfont("NimbusSan")
#ref("NimbusSan.png",center)
*** NimbusSanCond [#cc1121cc]
> epsfont("NimbusSanCond")
#ref("NimbusSanCond.png",center)
*** CenturySch [#p67baca2]
> epsfont("CenturySch")
#ref("CenturySch.png",center)
*** URWPalladio [#bf41bca4]
> epsfont("URWPalladio")
#ref("URWPalladio.png",center)
*** NimbusRom [#ve8b4b0b]
> epsfont("NimbusRom")
#ref("NimbusRom.png",center)
*** ComputerModern [#u2cb3246]
> epsfont("ComputerModern")
#ref("ComputerModern.png",center)
* pointsizeの指定 [#w1107c99]
点の大きさを指定できる
** pointsizeの指定例 [#eaebf640]
#ref(pointsize.png,center)
何故だがpointsizeを大きくすると描画領域が小さくなる。
* titleの指定 [#x62d8898]
これはグラフィックのmainオプションとは異なり、EPSファイル...
> dev.copy2eps(title="ADIS mortality in Honduras")
として、出力されたEPSファイルの中を見ると
%!PS-Adobe-3.0 EPSF-3.0
%%DocumentNeededResources: font Helvetica
%%+ font Helvetica-Bold
%%+ font Helvetica-Oblique
%%+ font Helvetica-BoldOblique
%%+ font Symbol
%%Title: ADIS mortality in Honduras
%%Creator: R Software
%%Pages: (atend)
%%BoundingBox: 0 0 268 263
%%EndComments
となっている。
* カラーのグラフィックをグレー階調のepsにする [#r1ffdbfd]
簡単にグレー階調になってくれないグラフィック関数を使って...
カラーのepsをグレー階調にする[[bw_convert:http://www-herm...
> pie(c(2,10,3),c("S","R","S-plus"))
> dev.copy2eps(file="カラー.eps")
> dev.copy2eps(file="| sed -e 's/\bsetrgbcolor\b/add add...
&ref("color-pie.png"); &ref("gray-pie.png");
また、ImageMagickのconvertを使う方法もあります。
> dev.copy2eps(file="| convert -type Grayscale - グレー...
Rによるeps出力は、フォントを埋め込まずベクター形式で、大...
* 暗色のスライド用に色を変更する [#e11bd97b]
プレゼンテーション用に色を反転させたグラフィックも同時に...
ここでは、昔懐かしいブルースライドにしてみます。
> par(bg='white') #背景色設定をepsに入れないと、そもそ...
> pie(c(2,10,3),c("S","R","S-plus"))
> dev.copy2eps(file="カラー.eps")
> blue.slide <- paste("| sed -e 's/\\bsetrgbcolor\\b/po...
+ "-e 's/\\b1 setgray\\b/0 0 0.6 setrgbcolor/g'",
+ "-e 's/\\b0 setgray\\b/1 setgray/g' > スライド.eps"...
> dev.copy2eps(file=blue.slide)
&ref("color-pie.png"); &ref("blue-pie.png");
ページ名: