axes
Axes.barh
创建一个水平条形图。
The bars are positioned at y with the given alignment. Their dimensions are given by width and height. The horizontal baseline is left (default 0).
Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar.
参数:
- y:float or array-like,bars的y坐标。
- width:float or array-like,bars的宽度
- height:float or array-like, default: 0.8,bars的高度
- left:float or array-like, default: 0,The x coordinates of the left sides of the bars.
- align:{‘center’, ‘edge’}, default: ‘center’,Alignment of the base to the y coordinates*:
‘center’: Center the bars on the y positions. ‘edge’: Align the bottom edges of the bars with the y positions. To align the bars on the top edge pass a negative height and align=‘edge’.
返回值:
- BarContainer:Container with all the bars and optionally errorbars.
其他参数:
pyplot
rcdefaults
subplots
matplotlib.pyplot.subplots
函数原型:
matplotlib.pyplot.subplots(
nrows=1,
ncols=1,
*,
sharex=False,
sharey=False,
squeeze=True,
subplot_kw=None,
gridspec_kw=None,
**fig_kw
)
函数创建一个figure以及一组subplots。
参数:
- nrows, ncols:(int类型,默认为1),指代subplot网格中的行数和列数
- 待补充
- **fig_kw:所有额外的关键字参数都会被传递给
pyplot.figure 调用
返回值:
- fig:(figure)
- ax:(axes.Axes)或者Axes数组:ax可以是单个的Axes对象,当创建多于一个subplot时ax就是Axes数组。The dimensions of the resulting array can be controlled with the squeeze keyword, see above.
常用的处理返回值的方式如下:
fig,ax=plt.subplots()
fig,axs=plt.subplots(2,2)
fig, (ax1, ax2) = plt.subplots(1, 2)
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.subplots.html#matplotlib.pyplot.subplots
|