0

I am working on a GUI plotting tool and need to split the contents of one matplotlib Figure object across two tkinter FigureCanvasTkAgg objects. In a previous iteration, I accomplished this by placing the legend and table outside of the borders of the plot using bbox() - but this does not gel with the "Reset Original View" in the matplotlib toolbar and causes the x-axis scale to change with each click of the button.

Shown below is how I am splitting apart these two canvases in tkinter

_______________________________________________________
[ main_plot_frame                                     ]
[   _______________________________________________   ]
[   [                          |                  ]   ]
[   [ plot_frame_canvas        | subplot_canvas   ]   ]
[   [   _____________________  |  _____________   ]   ]
[   [   [                   ]  |  [leg - ax2  ]   ]   ]
[   [   [  plot - ax1       ]  |  [           ]   ]   ]
[   [   [                   ]  |  [tbl - ax3  ]   ]   ]
[   [   [___________________]  |  [___________]   ]   ]
[   [                          |                  ]   ]
[   [__________________________|__________________]   ]
[                                                     ]
[_____________________________________________________]

It would be ideal to be able to user some call like

self.plot_frame_canvas.add_subplot(ax1)
self.subplot_canvas.add_subplot(ax2)
self.subplot_canvas.add_subplot(ax3)

self.plot_frame_canvas.draw()
self.subplot_frame_canvas.draw()

I have not so far found a way to do this in the MatPlotLib documentation - is there any easily accessible way to do something like this?

2
  • what "previous iteration" do you mean? If you asked other question before then add link in current question. Commented Jun 3 at 9:33
  • Axes belong to a single figure, so each of your canvases should have a separate figure created, and then add ax2 and ax3 to the figure on the right, and ax1 to the figure on the left. You may need to do fancy things to get the figures to talk to each other, but that is how Matplotlib works. You can't split figures across canvases and axes need to belong to the figure they are displayed in. Commented Jul 19 at 16:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.