Here is my problem:
I am learning python. I am trying to show 1 graph with 4 subgraphs on it.
The first time I use plt.show()
, I get my figure. The 2nd time, I get nothing.
Does anyone know why and how to fix this?
Here is my code:
>>> import seaborn as sns
>>> import matplotlib.pyplot as plt
>>> anscombe = sns.load_dataset("anscombe")
>>> dataset_1 = anscombe[anscombe['dataset'] == 'I']
>>> dataset_2 = anscombe[anscombe['dataset'] == 'II']
>>> dataset_3 = anscombe[anscombe['dataset'] == 'III']
>>> dataset_4 = anscombe[anscombe['dataset'] == 'IV']
>>> fig = plt.figure()
>>> axes1 = fig.add_subplot(2,2,1)
>>> axes2 = fig.add_subplot(2,2,2)
>>> axes3 = fig.add_subplot(2,2,3)
>>> axes4 = fig.add_subplot(2,2,4)
>>> axes1.plot(dataset_1['x'], dataset_1['y'], 'o')
[<matplotlib.lines.Line2D object at 0x000002088592D8D0>]
>>> axes2.plot(dataset_2['x'], dataset_2['y'], 'o')
[<matplotlib.lines.Line2D object at 0x000002088592DE80>]
>>> axes3.plot(dataset_3['x'], dataset_3['y'], 'o')
[<matplotlib.lines.Line2D object at 0x0000020885941A58>]
>>> axes4.plot(dataset_4['x'], dataset_4['y'], 'o')
[<matplotlib.lines.Line2D object at 0x0000020885941A20>]
>>> plt.show()
>>> plt.show()
Edit: I have searched other posts, but they did not help me. One that I searched for in particular was this one:Thread that did not help