我的问题是,当我展示自己的地块时,大熊猫将它们相互吸引。我希望它们在不同的图表上。该怎么做?
代码:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
train = pd.read_csv('./train.csv')
test = pd.read_csv('./test.csv')
survived = train[train['Survived'] == 1] # saving in variable all the people that survived
not_survived = train[train['Survived'] == 0] # saving in variable all the people that have not survived
tab = pd.crosstab(train['Pclass'], train['Sex'])
tab.div(tab.sum(1).astype(float), axis=0).plot(kind="bar", stacked=False)
train.groupby('Embarked').Survived.mean().plot(kind='line')
答案 0 :(得分:1)
这是如何将多个轴与熊猫图合并在一起
survived = train[train['Survived'] == 1] # saving in variable all the people that survived
not_survived = train[train['Survived'] == 0] # saving in variable all the people that have not survived
tab = pd.crosstab(train['Pclass'], train['Sex'])
fig, ax = plt.subplots(nrows = 1, ncols = 2, figsize = (10,5))
tab.div(tab.sum(1).astype(float), axis=0).plot(kind="bar", stacked=False, ax = ax[0])
train.groupby('Embarked').Survived.mean().plot(kind='line', ax = ax[1])