neh*_*eha 4 python plot matplotlib
我试图在Jupyter python笔记本中使用matplotlib绘制图形.但是当我分配y轴标签时,它没有显示在图表中,而且它也绘制了两个图形.我使用的代码是:
trans_count_month = df.groupby('month_').TR_AMOUNT.count()
plt.xlabel('Months') #X-axis label
plt.ylabel('Total Transactions Count') #Y-axis label
plt.title("Month wise Total Transaction Count") #Chart title.
width = 9
height = 5
plt.figure(figsize=(width, height))
trans_count_month.plot(kind='bar')
plt.figure(figsize=(width, height))
Run Code Online (Sandbox Code Playgroud)
如何只显示一个带有y轴标签的图形,如果还有其他方法可以绘制此图形,请分享解决方案.
这是一个最小的例子:
将pandas导入为pd
%matplotlib inline
from matplotlib import pyplot as plt
import pandas as pd
s = pd.Series([1,2,3], index=['a','b','c'])
s.plot.bar(figsize=(20,10))
plt.xlabel('Foo')
plt.ylabel('Bar')
plt.title("Hello World");
Run Code Online (Sandbox Code Playgroud)
哪个更好地利用熊猫和matplotlib.