maxframe.dataframe.Series.plot.barh#

Series.plot.barh(*args, **kwargs)#

制作水平条形图。

水平条形图是一种以矩形条长度与所代表数值成比例的方式展示定量数据的图表。条形图显示了离散类别之间的比较。图表的一个轴显示被比较的具体类别,另一个轴表示测量值。

参数:
  • x (label or position, optional) -- 允许绘制一列相对于另一列的图表。如果未指定,则使用 DataFrame 的索引。

  • y (label or position, optional) -- 允许绘制一列相对于另一列的图表。如果未指定,则使用所有数值列。

  • color (str, array-like, or dict, optional) --

    DataFrame各列的颜色。可能的值包括:

    • A single color string referred to by name, RGB or RGBA code, for instance 'red' or '#a98d19'.

    • A sequence of color strings referred to by name, RGB or RGBA code, which will be used for each column recursively. For instance ['green','yellow'] each column's bar will be filled in green or yellow, alternatively. If there is only a single column to be plotted, then only the first color from the color list will be used.

    • A dict of the form {column name : color}, so that each column will be colored accordingly. For example, if your columns are called a and b, then passing {'a': 'green', 'b': 'red'} will color bars for column a in green and bars for column b in red.

  • **kwargs -- 其他关键字参数请参考 DataFrame.plot()

返回:

subplots=True 时,返回一个ndarray,每列对应一个 matplotlib.axes.Axes

返回类型:

matplotlib.axes.Axes or np.ndarray of them

参见

DataFrame.plot.bar

Vertical bar plot.

DataFrame.plot

Make plots of DataFrame using matplotlib.

matplotlib.axes.Axes.bar

Plot a vertical bar plot using matplotlib.

示例

基本示例

(Source code)

将整个 DataFrame 绘制成水平条形图

(Source code)

绘制DataFrame的堆叠水平条形图

(Source code)

我们可以为每列指定颜色

(Source code)

将 DataFrame 的某一列绘制成水平条形图

(Source code)

绘制DataFrame与指定列的对比图

(Source code)