I am using matplotlib and Tkinter to plot some data. When I press a button, my graph is created in an independent window of given size. If I click again on the button, the graph is again created in the same position. Now, if I manually resize the window after pressing the button for the first time, the next time I press the button the window gets back to the original size that I set. Is there any way to ‘read’ the window size that I have manually modified with the mouse cursor so the next time the button is pressed the figure appears in the same window?
These are bits of my code:
plt.Figure()
thismanager = get_current_fig_manager()
thismanager.window.wm_geometry("500x500+890+300")
thismanager.set_window_title('Title')
plt.clf()
plt.xlabel('Xaxis',fontsize=16)
im=imshow(variableName,cmap='gray',origin='lower',vmin=0,vmax=255,interpolation='nearest')
cb=colorbar()
cb.set_label('Label',fontsize=16)
show()
I found myself a solution, this is the code: