import numpy as np import matplotlib. My question therefore is if there is a way to configure Matplotlib so that an aspect ratio of 'equal' is adjusted by the conversion factor between units, without having to compute the ratio by hand. As of matplotlib 3.3.0, tboxaspect seems to be the recommended approach. I was hoping the physical aspect ratio would be 2.54, after setting it to 'equal', but it's not. To run this, you also need basic_units.py I need it to be four times taller than it is wide (the plot is a 2D image). You can either do this with the adjustable kwarg when you create the subplots. You just need to make sure that adjustable is set to 'box' on your axes, and you have a set aspect ratio for the axes (anything other than 'auto' ). It's not what I want this for, but it is a fully-worked example. According to the official documentation of Matplotlib, we can use setaspect method of Axes class to set aspect ratio of an Axes object. I want to make a plot that has an unusual aspect ratio. 3 Answers Sorted by: 22 Actually, what you're wanting is quite simple. Here's an example to explain what I mean. I wanted to check here if that is the case, or if I'm missing something. It would seem that Matplotlib should be able to use units to accomplish the same thing automatically, but it looks as if units are not used in computing aspect ratios. ![]() The parameter of this method is a number which is a division of the X-axis with respect to the Y-axis. ![]() The method setaspect () is used to set the aspect ratio. It's quite ugly otherwise So, usually, I'm using axes().setaspect('equal') (because I want ALSO to remove the axis, and I can't use 'off' AND 'equal') from pylab but it doesn't work right here, only the 2nd picture appears. Setting the aspect ratio of the Matplotlib plot in Python As we are working on a graph we must focus on the division of both co-ordinates which is X and Y. ![]() In the past, I have done this manually by calculating the desired aspect ratio, but this was before I knew about the axis units capabilities in Matplotlib. I would like to plot 2 subplots in the same row with the same aspect ratio. I am looking for a way to define the aspect ratio of a 2D plot in Matplotlib, using axis units with pre-defined conversions. Insights New issue 3d plots with aspect'equal' 1077 Closed akhmerov opened this issue on 30 comments Contributor akhmerov commented on The figure is rendered with all axes scaled to the data scale, thus ignoring the aspect setting.
0 Comments
Leave a Reply. |