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 錦囊妙計
10.13 改變直線類型、寬度或顏色
|
275
延伸資訊
錦囊 10.1
10.13 改變直線類型、寬度或顏色
問題點
您正在繪製一條線;您想要改變它的類型、寬度,或線的顏色。
解決方案
使用
plot
函數(與其他圖形函數)時,一併設定線外觀的參數。為調整圖中直線類型,
可供設定之
lty
參數值如下:
lty="solid"
lty=1
(預設值)
lty="dashed"
lty=2
lty="dotted"
lty=3
lty="dotdash"
lty=4
lty="longdash"
lty=5
lty="twodash"
lty=6
lty="blank"
lty=0
(抑制繪圖)
如下所示,使用
plot
函數繪製虛線樣式(dashed style)的直線:
> plot(x, y, type="l", lty="dashed")
而且,使用
lwd
參數能控制線的寬度或厚度。預設情況下,線的寬度為 1
> plot(x, y, type="l", lwd=2) # 繪製較粗的線
此外,使用
col
參數控制線的顏色。預設情況下,線的顏色為黑色:
> plot(x, y, type="l", col="red") # 繪製紅線
討論說明
雖然解決方案提供繪製一條直線與設定其樣式、寬度或顏色的方法,但是對於繪製多條
線,且每條線各有其風格、寬度,或顏色之情況,解決方案亦可適用。然而,不同之處
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