1. 程式人生 > >matplotlib(二):折線圖

matplotlib(二):折線圖

seq eps HR ide () markers 參數設置 ger 內容

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

# 解決中文顯示問題
plt.rcParams[font.sans-serif] = [STLiti]  # 用來正常顯示中文標簽
plt.rcParams[axes.unicode_minus] = False  # 用來正常顯示負號
# 有中文出現的情況,需要u‘內容‘

fig = plt.figure()
ax1 = fig.add_subplot(111)
#設置標題
ax1.set_title(折線圖
) #設置X軸標簽 plt.xlabel(X) #設置Y軸標簽 plt.ylabel(Y) x=np.linspace(-10,10,100)# -10到10平均分成100份 y=x**3 # plt.plot(x,y) # 方式一 ax1.plot(x, y, color=green, linestyle=dashed, marker=o, markerfacecolor=blue, markersize=12) #設置圖標 plt.legend(x) plt.show()

plt.plot()參數設置

PropertyValue Type
alpha 控制透明度,0為完全透明,1為不透明
animated [True False]
antialiased or aa [True False]
clip_box a matplotlib.transform.Bbox instance
clip_on [True False]
clip_path a Path instance and a Transform instance, a Patch
color or c 顏色設置
contains the hit testing function
dash_capstyle [‘butt’ ‘round’ ‘projecting’]
dash_joinstyle [‘miter’ ‘round’ ‘bevel’]
dashes sequence of on/off ink in points
data 數據(np.array xdata, np.array ydata)
figure 畫板對象a matplotlib.figure.Figure instance
label 圖示
linestyle or ls 線型風格[‘-’ ‘–’ ‘-.’ ‘:’ ‘steps’ …]
linewidth or lw 寬度float value in points
lod [True False]
marker 數據點的設置[‘+’ ‘,’ ‘.’ ‘1’ ‘2’ ‘3’ ‘4’]
markeredgecolor or mec any matplotlib color
markeredgewidth or mew float value in points
markerfacecolor or mfc any matplotlib color
markersize or ms float
markevery [ None integer (startind, stride) ]
picker used in interactive line selection
pickradius the line pick selection radius
solid_capstyle [‘butt’ ‘round’ ‘projecting’]
solid_joinstyle [‘miter’ ‘round’ ‘bevel’]
transform a matplotlib.transforms.Transform instance
visible [True False]
xdata np.array
ydata np.array
zorder any number

matplotlib(二):折線圖