I am creating about one dozen figures with subplots. There is one subplot that is the same for all the figures. However, it takes a loonnggg time to draw. Is there a way to only draw this subplot once and then replicate it in each figure? (Not the same thing as this accepted answer, which just defines a function that redraws the subplot every time.)
A snippet of the large source data file for the slow-drawing plot is below, as well as my current code for generating the subplot.
Code:
fig1 = plt.figure()
ax1 = plt.subplot2grid((2,2), (0,0), rowspan=2, colspan=1)
for ii in df_lines.Line_ID: ## df_lines.Line_ID = max(df_points.ID)
temp = df_points.loc[df_points.ID == ii]
df_myline = temp.sort_values(by='Order_ID', ascending=True)
del temp
x = df_line.X
y = df_line.Y
ax1.plot(x, y)
df_points Snippet: Note there are decimals here in X,Y they just got cut off here
ID Order_ID X Y
1 1 -116 35
1 2 -116 35
2 1 -116 35
2 2 -116 35
3 1 -116 35
3 2 -116 35
3 3 -116 35
4 1 -116 35
4 2 -116 35
5 1 -116 35
5 2 -116 35
6 1 -116 35
6 2 -116 35
7 1 -116 35
7 2 -116 35
8 1 -116 35
8 2 -116 35
9 1 -116 35
9 2 -116 35
10 1 -116 35
10 2 -116 35
10 3 -116 35
10 4 -116 35
10 5 -116 35