import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='blue')
ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9),
facecolors=('red', 'yellow', 'green'))
ax.set_ylim(5, 35)
ax.set_xlim(0, 200)
ax.set_xlabel('seconds since start')
ax.set_yticks([15, 25])
ax.set_yticklabels(['Bill', 'Jim'])
ax.grid(True)
ax.annotate('race interrupted', (61, 25),
xytext=(0.8, 0.9), textcoords='axes fraction',
arrowprops=dict(facecolor='black', shrink=0.05),
fontsize=16,
horizontalalignment='right', verticalalignment='top')
plt.show()
broken_barh:方括号里,小括号里,第一个数字是起点位置,第二个数字是长度。
非方括号的小括号:
facecolors:条形的颜色。
set_ylim:
set_xlim:x轴的长度?
set_xlabel:X轴的标签名称
set_yticks:
set_yticklabels:
grid
annotate
不存在:
Horizontal bar chart
等待:
Plotting categorical variables
Plotting the coherence
CSD Demo
Errorbar limit selection
Errorbar Subsample
EventCollection Demo
Eventplot Demo
Filled ploygon
Filling the area between
FillBetweenx Demo
Hatch-filled histograms
Bar chart with gradients
Discrete distribution as horizontal bar chart
Join styles and cap styles
Customizing dashed line styles
Linestyles
Marker filling-styles
Marker Reference
Markevery Demo
prop_cycle property markevery in reParams
Masked Demo
Multicolored lines
Nan Test
Psd Demo
Scatter Custom Symbol
Scatter Demo2
Scatter plot with histograms
Scatter Masked
Scatter plot with pie chart markers
Scatter Star Poly
Scatter Symbol
Scatter plots with legend
Simple Plot
Using span_where
Spectrum Representations
Stackplot Demo
Stem Plot
Step Demo
Creating a timeline with lines, dates and text
hlines and vlines
Cross- and Auto- Correlation Demo