'Pandas jupyter notebook plotting many windows instead of one
I am trying to plot the histogram of a pandas dataframe and overlay the histogram with a curve. I am running the code in jupyter-notebook and I find that instead of displaying one image with the histogram, overlay plot, and axes labels, I see three separate plots. I have tried ioff, savefig, but no use. The code and output are as linked in the first comment (sorry I was having trouble with stackoverflow code formatting with figure), what I would want to see is also attached (for a different dataset. desired results image courtesy: towardsdatascience).
fig, ax = plt.subplots(figsize = (6,4))
# X #
ax.set_xlabel("Value")
# Limit x range to 0-4
ax.set_xlim(0, 0.03)
# Y #
ax.set_ylim(0,1)
# Remove y ticks
ax.set_yticks([])
# Relabel the axis as "Frequency"
ax.set_ylabel("Frequency")
# Overall #
ax.set_title("RMS (Sky + CD model - Smooth fit)")
# Plot histogram
rms_df.plot(kind = "hist", density = True, bins = 15) #
# Plot KDE
rms_df.plot(kind = "kde")
plt.show()
plt.savefig('res_hist_v2.svg', format='svg', dpi=1200)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
