## [Matplotlib-users] absolute positioning of a subplot in a Figure

 [Matplotlib-users] absolute positioning of a subplot in a Figure From: TP - 2008-09-29 19:10:18 ```Hi everybody, Below you will find a small script that plots the graph of a simple function. This code is aimed to be embedded in a GUI application. I set the subplot dimension with the b.set_position([]) command. The floats that are given to set_position() are percents relative to the Figure dimensions: [ left corner x, left corner y, width, height ] So, here I have put [0.1, 0.1, 0.8, 0.8 ] to have a small space between the subplot and the Figure border. But when I resize the figure with the mouse, the space between the subplot and the Figure border is growing or decreasing, due to the relative definition of the dimensions. I would like to be able to define subplot size and position in an absolute way. For example, I would like to have a space between the left border of the figure and the left border of the subplot being constant equal to 10px. Is this possible? Thanks a lot Julien #################### from pylab import * import Tkinter as Tk from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg root = Tk.Tk() t = arange(0.01, 5.0, 0.01) s1 = sin(2*pi*t) f = Figure( figsize = (8,7) ) veryplot = FigureCanvasTkAgg( f , master = root ) veryplot.get_tk_widget().pack( side = Tk.LEFT , expand = Tk.YES , fill = Tk.BOTH ) b = f.add_subplot( 211 ) b.plot( t, s1 ) # [ left corner x, left corner y, width, height ] b.set_position( [ 0.1, 0.1, 0.8, 0.8 ] ) show() root.mainloop() #################### ```

 [Matplotlib-users] absolute positioning of a subplot in a Figure From: TP - 2008-09-29 19:10:18 ```Hi everybody, Below you will find a small script that plots the graph of a simple function. This code is aimed to be embedded in a GUI application. I set the subplot dimension with the b.set_position([]) command. The floats that are given to set_position() are percents relative to the Figure dimensions: [ left corner x, left corner y, width, height ] So, here I have put [0.1, 0.1, 0.8, 0.8 ] to have a small space between the subplot and the Figure border. But when I resize the figure with the mouse, the space between the subplot and the Figure border is growing or decreasing, due to the relative definition of the dimensions. I would like to be able to define subplot size and position in an absolute way. For example, I would like to have a space between the left border of the figure and the left border of the subplot being constant equal to 10px. Is this possible? Thanks a lot Julien #################### from pylab import * import Tkinter as Tk from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg root = Tk.Tk() t = arange(0.01, 5.0, 0.01) s1 = sin(2*pi*t) f = Figure( figsize = (8,7) ) veryplot = FigureCanvasTkAgg( f , master = root ) veryplot.get_tk_widget().pack( side = Tk.LEFT , expand = Tk.YES , fill = Tk.BOTH ) b = f.add_subplot( 211 ) b.plot( t, s1 ) # [ left corner x, left corner y, width, height ] b.set_position( [ 0.1, 0.1, 0.8, 0.8 ] ) show() root.mainloop() #################### ```