簡體   English   中英

在Jupyter iPython Notebook中使用matplotlib繪制圖形

[英]Plotting graph using matplotlib in Jupyter iPython Notebook

我試圖在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))

我得到的輸出是: 在此輸入圖像描述

如何只顯示一個帶有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");

在此輸入圖像描述

哪個更好地利用熊貓和matplotlib。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM