使用索引作为X轴标签绘制直方图 [英] Plot a histogram using the index as x-axis labels

查看:128
本文介绍了使用索引作为X轴标签绘制直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python中有以下数据框

I have the following dataframe in python

  Sex  Survived
0  female  0.742038
1    male  0.188908

我想绘制一个直方图,其中,男性和女性是x轴上的两个值,而y轴具有其相应的值.任何想法如何? .我是Matplotlib和Pandas的新手,所以请帮忙

i would like to plot a histogram, where male and female are the two values in the x-axis and y axis has its corresponding values. Any idea how ? . I am new to matplotlib and pandas, so please help

推荐答案

在我看来,您需要

In my opinion you need DataFrame.plot.bar:

df.plot.bar(x='Sex', y='Survived')

因为 histogram 绘制数字数据的分布图.

because histogram plot distribution of numerical data.

这篇关于使用索引作为X轴标签绘制直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆