Issue
I am learning visualization techniques in Python. I would like to plot two graphs vertically. Here is my code:
import seaborn as sns
import matplotlib.pyplot as plt
kernel_avg_es_100 = sns.kdeplot(data=avg_100_data, x="AVGT")
plt.xlabel("Average temperature estimates")
kernel_avg_se_100 = sns.kdeplot(data=avg_100_data, x="SE AVGT")
plt.xlabel("Average temperature SE")
(kernel_avg_es_100, kernel_avg_se_100) = plt.subplots(2)
plt.show()
But it got only an empty plot:
I follow the advice here: https://matplotlib.org/devdocs/gallery/subplots_axes_and_figures/subplots_demo.html
Can you help me with how to get the desired output, please?
Solution
You can try something like this:
fig, (ax1, ax2) = plt.subplots(2, 1)
sns.kdeplot(data=avg_100_data, x="AVGT", ax=ax1)
ax1.set_xlabel("Average temperature estimates")
sns.kdeplot(data=avg_100_data, x="SE AVGT", ax=ax2)
ax2.set_xlabel("Average temperature SE")
plt.tight_layout()
plt.show()
(Dummy data)
Answered By - Corralien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.