简体   繁体   English

使用 matplotlib 的基本条形图

[英]Basic bar plot using matplotlib

I've created a very basic dataframe, but as I'm a newbie I'm struggling with creating a bar plot using the matplotlib.pyplot library.我创建了一个非常基本的数据框,但由于我是新手,我正在努力使用 matplotlib.pyplot 库创建条形图。

Here is the dataframe:这是数据框:

d = {'Movies' : pd.Series([3560, 12354], index = ['Netflix', 'Prime Video']),
     'Shows' : pd.Series([1925, 2132], index = ['Netflix', 'Prime Video'])
    }

df = pd.DataFrame(d)
df

Is it possible to have 'Streaming Service' on the x-axis (ie Netflix and Prime Video) and 'Number' on the y-axis (with different coloured bars for movies vs shows)?是否可以在 x 轴(即 Netflix 和 Prime Video)上使用“流媒体服务”,在 y 轴上使用“数字”(电影与节目的颜色条不同)?

This is as simple as df.plot.bar() :这就像df.plot.bar()一样简单:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM