matplotlib畫圖plot線型設定

來源:互聯網
上載者:User
本文是學習《matplotlib for python developers》的一點筆記
plot畫圖時可以設定線條參數。包括:顏色、線型、標記風格。
1)控制顏色
顏色之間的對應關係為
b---blue   c---cyan  g---green    k----black
m---magenta r---red  w---white    y----yellow
有三種表示顏色的方式:
a:用全名  b:16進位如:#FF00FF  c:RGB或RGBA元組(1,0,1,1) d:灰階強度如:‘0.7’
2)控制線型
符號和線型之間的對應關係
-      實線
--     短線
-.     短點相間線
:     虛點線

3)控制標記風格
標記風格有多種:
.  Point marker
,  Pixel marker
o  Circle marker
v  Triangle down marker 
^  Triangle up marker 
<  Triangle left marker 
>  Triangle right marker 
1  Tripod down marker
2  Tripod up marker
3  Tripod left marker
4  Tripod right marker
s  Square marker
p  Pentagon marker
*  Star marker
h  Hexagon marker
H  Rotated hexagon D Diamond marker
d  Thin diamond marker
| Vertical line (vlinesymbol) marker
_  Horizontal line (hline symbol) marker
+  Plus marker
x  Cross (x) marker
下面的執行個體集合以上三種:具體代碼和效果如下所示:
[python]  view plain  copy import matplotlib.pyplot as plt    import numpy as np    y = np.arange(1, 3, 0.3)    plt.plot(y, 'cx--', y+1, 'mo:', y+2, 'kp-.');   plt.show()  



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.