I have two files with data: datafile1 and datafile2, the first one always is present and the second one only sometimes. So the plot for the data on datafile2 is defined as a function (geom_macro) within my python script. At the end of the plotting code for the data on datafile1 I first test that datafile2 is present and if so, I call the defined function. But what I get in the case is present, is two separate figures and not one with the information of the second one on top of the other. That part of my script looks like this:
f = plt.figuire()
<in this section a contour plot is defined of datafile1 data, axes, colorbars, etc...>
if os.path.isfile('datafile2'):
geom_macro()
plt.show()
The "geom_macro" function looks like this:
def geom_macro():
<Data is collected from datafile2 and analyzed>
f = plt.figure()
ax = f.add_subplot(111)
<annotations, arrows, and some other things are defined>
Is there a way like "append" statement used for adding elements in a list, that can be used within matplotlib pyplot to add a plot to an existing one? Thanks for your help!