Skip to Content
R 錦囊妙計
book

R 錦囊妙計

by Paul Teetor
January 2014
Beginner to intermediate
488 pages
8h 1m
Chinese
GoTop Information, Inc.
Content preview from R 錦囊妙計
298
|
第十章
然而,此錦囊的解決方案在批次處理的腳本中則不同:
呼叫函數來開啟一個新的圖形檔案,如
png(...)
jpeg(...)
呼叫
plot
函數與其參數,繪製產生圖形。
呼叫
dev.off()
來關閉圖形檔案。
其中,開啟圖形檔案的函數取決於您的平台和檔案格式。同樣地,參考
help(Devices)
輔助網頁關於您平台可用的函數列表。例如,一個常見的函數是
png
,用來產生一個
PNG 檔案,它使用的方法如下:
> png("filename.ext", width=w, height=h)
其中,
w
為期望的寬度,
h
為期望的高度,兩者皆以像素表示。如下所示,使用
png
數,它會執行繪圖並產生圖形檔案
myPlot.png
> png("myPlot.png", width=648, height=432) # 或者任何適合的尺寸大小
> plot(x, y, main="Scatterplot of X, Y")
> dev.off()
延伸資訊
錦囊 3.1 關於目前工作目錄。
10.29 改變圖形參數
問題點
您想改變一個圖形的整體參數,如:直線類型、背景顏色,或字體大小。
解決方案
使用
par
函數,設定整體圖形參數值。例如,使用
par
函數將預設的行寬由 1 改為 2
> par(lwd=2)
討論說明
每個圖形的形成基於許多假設。線應該多寬?背景顏色為何?前景色為何?字體為何?
邊距多寬?假設答案是由整體圖形參數及其預設值所設定,我們得感謝那些預設值;否
則,即使是繪製最簡單的圖形,也將因為設定每個細節而帶來許多困擾。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

R 语言经典实例(原书第 2 版)

R 语言经典实例(原书第 2 版)

J.D. Long, Paul Teetor
優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769829