Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

Why did the plotting drop down? (Seaborn, Python)

f, ax=plt.subplots(1,2, figsize=(10,6))

sns.barplot('Parch','Survived', data=data, ax=ax[0])
ax[0].set_title('Parch vs Survived')

sns.factorplot('Parch','Survived', data=data, ax=ax[1])
ax[1].set_title('Parch vs Survived')

plt.show()

As a result, the frist_plot goes well but the second plotting is separated and drops down.I add the result_image for illustration: enter image description here

Why is the second sns.plot separated to down, and what do I have to do?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use this:

f, ax=plt.subplots(1,2, figsize=(10,6))
sns.barplot('parch','survived', data=data, ax=ax[0])
sns.factorplot('parch','survived', data=data, ax=ax[1])
plt.close(2)
plt.close(3)

Here you can find more information on why this is happening.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...