当我在IPython上使用Pandas执行以下操作时,它只显示我绘制的最后一张图片,有没有办法让它们在IPython上按顺序显示?
def drawBar(colName):
df1=df[colName].value_counts().plot(kind='bar', title=colName)
drawBar("myBiscuit")
drawBar("myBedRoom")
...(many more drawBar)
答案 0 :(得分:2)
为了在笔记本中绘制图形,您可以使用IPython魔术php artisan migrate
。
您需要为每个图表调用[Illuminate\Database\QueryException]
SQLSTATE[08006] [7] SSL SYSCALL error: Broken pipe
expected authentication request from server, but received S (SQL: select *
from information_schema.tables where table_schema = public and table_name = migrations)
。这将在您的IPython中返回一长串的图表。
%matplotlib inline
可以使用plt.show()
创建多个子图。然后使用pandas plotting函数的import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
%matplotlib inline
colNames = "ABCDEFGHI"
x = np.random.randint(0,5, size=(10, 9))
df = pd.DataFrame(x, columns=[letter for letter in colNames])
def drawBar(colName):
df1=df[colName].value_counts().plot(kind='bar', title=colName)
for i in range(9):
drawBar(colNames[i])
plt.show()
关键字参数,在指定的轴上创建图形。
plt.subplots()