Matplotlib 3.5.x breaks some plots
See original GitHub issueMatplotlib >= 3.5 seems to break plot sizes and patches in sectionproperties. Example below:
import sectionproperties.pre.library.steel_sections as steel_sections
from sectionproperties.analysis.section import Section
# Create a 150x100x6 RHS on its side
geometry = steel_sections.rectangular_hollow_section(d=100, b=150, t=6, r_out=15, n_r=8)
# Create a mesh and section object. For the mesh, use a maximum area of 2
geometry.create_mesh(mesh_sizes=[2])
section = Section(geometry)
# Perform a geometry and warping analysis
section.calculate_geometric_properties()
section.calculate_warping_properties()
# Perform a stress analysis with Mx = 5 kN.m; Vx = 10 kN and Mzz = 3 kN.m
case1 = section.calculate_stress(Mxx=5e6, Vx=10e3, Mzz=3e6)
Plot sizes are much smaller and patches are far less transparent(?) by default (images have been scaled in ratio to their original size - best to view on computer screen but image width and height are both approximately halved):
section.plot_mesh()
matplotlib==3.4.2
matplotlib==3.5.1
case1.plot_stress_vm()
matplotlib==3.4.2
matplotlib==3.5.1
Is the answer to, for now, require matplotlib < 3.5? Patches may be able to be sorted by passing an alpha value as an argument but not sure how to handle the plot size reducing? Haven’t had much of a look at it yet thought…
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Broken Axis — Matplotlib 3.6.2 documentation
Broken axis example, where the y-axis will have a portion cut out. ... So let's 'break' or 'cut-out' the y-axis # into two...
Read more >Break // in x axis of matplotlib - python - Stack Overflow
I'm quite certain it is achievable with gridpsec but an advanced tutorial cover exactly how this is achieved would be greatly appreciated.
Read more >[BUG] matplotlib 3.5.2 breaks our plotting wrapper #340 - GitHub
[BUG] matplotlib 3.5.2 breaks our plotting wrapper #340 ... previous versions work until the new 3.5.2 released today breaks the wrapper.
Read more >brokenaxes - PyPI
brokenaxes makes matplotlib plots with breaks in the axes for showing data across a discontinuous range. PyPI - Downloads. Features. Break x and...
Read more >Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib is a multiplatform data visualization library built on NumPy arrays, ... At this point, any plt plot command will cause a figure...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yea, I agree with your assessment but I’d also argue that it’s best to pass args, or at least kwargs, to the plotting function which would provide a better user experience (instead of having to manually do it after the figure and axes are returned).
I closed that PR of mine because I incorporated it into my much larger one! Maybe that was the wrong idea…I should have kept the whole thing as a bunch of smaller ones, but there were so many changes that it was easier to make them all together. Regardless, those changes are still reflected in the other PR of mine. Mainly it changes it to a context manager and passes those kwargs as I said and also allows saving the file directly. When doing multiple sections, I’d rather be able to save all the files directly and then continue to the next analysis without needing to ever have the figures pop up on screen.
Yes, another point is that it really isn’t necessary to return the figure along with the axes as it is very easy to get the figure if you want it (
ax.get_figure()
). This is why some libraries, like seaborn, only return the axes.Alternatively, you could return only the figure and then get the axes from the figure. But it is much more common in other libraries to return just the axes.