Matplotlib, Qt, and borders

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Matplotlib, Qt, and borders

Israel Brewster
I’m new to matplotlib, and using it in conjunction with Qt as per https://matplotlib.org/gallery/user_interfaces/embedding_in_qt_sgskip.html, which works well. However, I’m struggling with borders, especially as the user resizes the window. 

What it looks like is that the left, right, bottom and top parameters to subplots_adjust are in percents - is that correct? If so, is there a way to change it to pixels? As things stand, when the user adjusts the size of the window, the “gap” between an edge of the graph and the edge of the container changes. More troubling is that as the window gets smaller, the graph labels get cut off.

Ideally I’d like to be able to say “fit the entire graph (including axes labels) inside the parent object with x number of pixels padding on each side”. Of course there would be some minimum size you couldn’t effectively go below. Is that possible?
---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Matplotlib, Qt, and borders

tcaswell
Israel,

You probably want to use `tight_layout` or `constrained_layout` on the embedded figure.

Setting axes position in pixels would get messy if you have more than one Axes in the figure and you want to handle resizing. 

See https://matplotlib.org/tutorials/advanced/transforms_tutorial.html#transformations-tutorial for the stacked coordinate systems that Matplotlib uses.

Tom


On Fri, Mar 29, 2019 at 1:44 PM Israel Brewster <[hidden email]> wrote:
I’m new to matplotlib, and using it in conjunction with Qt as per https://matplotlib.org/gallery/user_interfaces/embedding_in_qt_sgskip.html, which works well. However, I’m struggling with borders, especially as the user resizes the window. 

What it looks like is that the left, right, bottom and top parameters to subplots_adjust are in percents - is that correct? If so, is there a way to change it to pixels? As things stand, when the user adjusts the size of the window, the “gap” between an edge of the graph and the edge of the container changes. More troubling is that as the window gets smaller, the graph labels get cut off.

Ideally I’d like to be able to say “fit the entire graph (including axes labels) inside the parent object with x number of pixels padding on each side”. Of course there would be some minimum size you couldn’t effectively go below. Is that possible?
---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Matplotlib, Qt, and borders

Israel Brewster
Tight_layout seems to overlap things in my experience, but I’ll give it another shot. Constrained_layout I’m not familiar with, so definitely something to try. Thanks.

I’ve always found pixel layout to be much cleaner than percent layouts, but then I’m used to designing web interfaces with a bunch of objects that need to play together nicely when you resize the window, so this is a significantly different application. That said, I was thinking along the lines of setting the border for the figure, not individual axis, but perhaps that’s not how it works?

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

On Mar 29, 2019, at 11:44 AM, Thomas Caswell <[hidden email]> wrote:

Israel,

You probably want to use `tight_layout` or `constrained_layout` on the embedded figure.

Setting axes position in pixels would get messy if you have more than one Axes in the figure and you want to handle resizing. 

See https://matplotlib.org/tutorials/advanced/transforms_tutorial.html#transformations-tutorial for the stacked coordinate systems that Matplotlib uses.

Tom


On Fri, Mar 29, 2019 at 1:44 PM Israel Brewster <[hidden email]> wrote:
I’m new to matplotlib, and using it in conjunction with Qt as per https://matplotlib.org/gallery/user_interfaces/embedding_in_qt_sgskip.html, which works well. However, I’m struggling with borders, especially as the user resizes the window. 

What it looks like is that the left, right, bottom and top parameters to subplots_adjust are in percents - is that correct? If so, is there a way to change it to pixels? As things stand, when the user adjusts the size of the window, the “gap” between an edge of the graph and the edge of the container changes. More troubling is that as the window gets smaller, the graph labels get cut off.

Ideally I’d like to be able to say “fit the entire graph (including axes labels) inside the parent object with x number of pixels padding on each side”. Of course there would be some minimum size you couldn’t effectively go below. Is that possible?
---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320
Work: 907-474-5172
cell:  907-328-9145

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users