0

I am using following code to plot 2 different plot(count of visit) from 2 different columns of a CSV file. But the 2nd graph is displaying only after I close the 1st graph. Is it possible to display 2 plots together?

import matplotlib.pyplot as plt
import pandas
import csv
import pandas as pd
import matplotlib

output2 =pandas.read_csv('Place.csv')
place_plot= output2.Place.value_counts().plot(kind="bar",x=output2["Place"],title="Count",legend=False)
plt.show()
capital_plot= output2.Capital.value_counts().plot(kind="bar",x=output2["Capital"],title="Count",legend=False)
plt.show()

Place.csv file has following data:

Name    Place   Capital
A   India   Delhi
B   USA Wash
C   India   Delhi
D   USA Wash
E   China   Bej
F   UK  Lon
G   Canada  un
H   China   Bej
I   UK  Lon
J   UK  Lon

2 Answers 2

2

plt.show() will produce the figure window(s). If you call it inthe middle of the script, the script will stop until the window is closed.

If you only call plt.show() once at the end, all figures which are produced by the script will be shown at once.

Sign up to request clarification or add additional context in comments.

Comments

0

Subplot will show two plots side by side:

plt.subplot(1,2,1)
place_plot =output2.Place.value_counts().plot(kind="bar",x=output2["Place"],title="Count",legend=False)
 plt.subplot(1,2,2)
capital_plot= output2.Capital.value_counts().plot(kind="bar",x=output2["Capital"],title="Count",legend=False)
plt.show()

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.