1st Plot
> `This code is under a while loop`
> `This is the code for 1st graph`
> `it works fine until i added plt.figure()`
a1=plt.figure(1)
df.set_index("Date",inplace=True)
df[["inflow","outflow"]].plot(kind='bar',color=['Green','Red'])
plt.xlabel("Date")
plt.ylabel("Amount")
plt.title(file)
plt.subplots_adjust(bottom=0.25)
a1.show()
2nd Plot
`This is code for 2nd graph and main problem it did show simultaneously`
`But it is always empty even though i copied same data in both file`
a2=plt.figure(2)
Year = int(input("Which Years Data You Want to Visualise (YYYY): "))
Month = int(input("Enter Which month of above mentioned Year (MM): "))
This is a self main modula only used to convert No. of month to Their Name
MN=DayTimeMonth.Month_Name_oprational(Month)
dft="{}-{}.csv".format(MN,Year)
try:
df2=pd.read_csv(dft)
Handling File not Found error
except FileNotFoundError:
print("No record Found for {}")
break
Handeling Empty data error
except pd.errors.EmptyDataError:
print("Oprations Cannot be performe on empty CSV file")
break
Setting Index for proper ploting
df2.set_index("Date",inplace=True)
`this the line on which basis the graph has to be plot`
df2[["inflow","outflow"]].plot(kind='bar',color=['Green','Red'])
plt.xlabel("Date")
plt.ylabel("Amount")
plt.title(file)
plt.subplots_adjust(bottom=0.25)
a2.show()
input()
break
To show two plots next to each other, you need to call
plt.subplotsrather thanplt.figure, e.g.Also check this demo on subplots: https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html