Bit of an odd one, and I'm clearly missing something, but I'm getting some really weird behaviour, and I can't work out what I'm doing wrong.
I have a plot with subplots in a grid format (for the sake of this post, I'll say just a 2 by 2 grid). I want to plot some stuff on each and also add a circle. Should be easy, but it's not acting as I expect.
Example Code 1:
import matplotlib.pyplot as plt
x = [ -1.0, -0.5, 0.0, 0.5, 1.0 ]
y = [ 0.7, 0.2, 1.0, 0.0, 0.0 ]
circle = plt.Circle( ( 0, 0 ), 1 )
fig, axes = plt.subplots( 2, 2 )
axes[ 0, 0 ].plot( x, y )
axes[ 1, 1 ].plot( x, y )
axes[ 0, 0 ].add_patch( circle )
axes[ 1, 1 ].add_patch( circle )
plt.show( )
Output 1:
Example Code 2:
import matplotlib.pyplot as plt
x = [ -1.0, -0.5, 0.0, 0.5, 1.0 ]
y = [ 0.7, 0.2, 1.0, 0.0, 0.0 ]
circle = plt.Circle( ( 0, 0 ), 1 )
fig, axes = plt.subplots( 2, 2 )
axes[ 0, 0 ].plot( x, y )
axes[ 1, 1 ].plot( x, y )
axes[ 0, 0 ].add_patch( circle )
#axes[ 1, 1 ].add_patch( circle )
plt.show( )
Output 2:
Example Code 3:
import matplotlib.pyplot as plt
x = [ -1.0, -0.5, 0.0, 0.5, 1.0 ]
y = [ 0.7, 0.2, 1.0, 0.0, 0.0 ]
circle = plt.Circle( ( 0, 0 ), 1 )
fig, axes = plt.subplots( 2, 2 )
axes[ 0, 0 ].plot( x, y )
axes[ 1, 1 ].plot( x, y )
#axes[ 0, 0 ].add_patch( circle )
axes[ 1, 1 ].add_patch( circle )
plt.show( )
I really don't understand this behaviour (why does example 2 work but not 1 or 3?), or what I'm doing to cause it. Can anyone shed some light? Thanks in advance.


