matplotlib figure size aspect ratio - matplotlib

In matplotlib, if I see the aspect ratio of the image using
ax.set_aspect('equal')
is there a way I can get the actual figure to also match that? Currently, I just get a lot of grey space.

Related

Update and Display a Coordinate Axis being Rotating and Translated in Real Time in Matplotlib?

I'm currently trying to recreate this: video, and I could not find how to recreate the 3D visualization step, where coordinate axis are translated and rotated around, in matplotlib. Does anyone know how to do in matplotlib's animation, updating the results in real time?

Relative figure size in matplotlib

Pretty much it -- is there any way to do it platform-, respectively, backend-independently? In MATLAB, say, it's not a problem, whereas matplotlib doesn't even seem to support different units but inches.
If you know the dpi of your screen you can convert inches to pixels. But it will work only for screens with the same dpi. Otherwise you have to work with the backend to get the correct size and position of the figure canvas on the screen in pixels

Re-sizing visual image while maintaining image dimensions

I'm working with documents, so maintaining the the original image dimensions and subsequent dpi is important.
The aspect ratio is always maintained so the automatic fill modes and alike don't seem to have any effect.
Say I have a 300 dpi document and the user want to clear an inch border around the image. So I need an inch cropped from the image but the result needs to be the original image dimensions (2550x3300).
I have been able to achieve this effect with...
...&crop=300,300,-300,-300&margin=300,300,300,300
This works, but seems more than a little clunky. I've tried a lot of other combinations but they all seem to enlarge or reduce the image size which is undesirable in my case.
So does someone know a simpler syntax to achieve the desired result, or do I need to re-size the image then calculate and fill with a margin as I'm doing now.
Thanks
It turns out that my example requests the image in it's full size which turns out to be a special case. When I introduce a width or height into the command line things don't work very well since crop size is in respect to the original image dimensions and margin size is in respect to the result image.
Thinking about it more I abandoned the crop approach. What I really needed was a way to introduce a clipping region into the result bitmap. So I built an extension to do just that. It works well as it doesn't interfere with any of Resizer's layout calculations and the size of the returned image is whatever the height or width were specified as. Which is just what I needed. The Faces plugin has an example of introducing a clipping region.
Karlton
Cropping and re-adding 300px on each edge is best accomplished exactly the way you're doing it:
&crop=300,300,-300,-300&margin=300
What kind of improved syntax would you expect? This isn't a common operation.

matplotlib, how change plot size without affecting axis label

I want to make a plot in matplotlib that is wide and short. I can manipulate the size of a plot as answered on this question.
However, the x-axis label disappears if the plot is not tall enough. I want to squeeze the plot more while keeping the axis label visible.
Is there a way to manipulate the size of the plot without getting rid of the axis label?
After you change the plot size, run tight_layout(). Note that this requires matplotlib v1.1 or newer. If you have an older version of matplotlib, you can run subplot_tool() or subplots_adjust to adjust the plot manually.

How to move a Core Plot graph

I have a Core-Plot Graph within a Mac Application. But the inside table is appearing shifted down and to the left of the containing "frame/border" so that neither of the axis' are showing. I cannot figure out how to change this does anyone know what parameters I need to change to fix this?
Update: Sorry I did not realize I could upload an image, I have done so know and will try your suggestions in the mean-time.
Not sure what you mean by "inside table". It would be easier to offer suggestions if you could post a screenshot.
Without seeing what's wrong, here are some common areas to look at:
If you haven't already done so, look at the example apps included with Core Plot for ideas. The Plot Gallery app has many sample plots and the others are useful, too.
You may need to add padding (paddingLeft, paddingBottom, etc.) on the graph and/or plot area frame. Padding the graph pushes everything in away from the edges of the graph. Padding the plot area frame pushes the plot area in so the axes and titles can hang outside the plot area (the area where the plots are drawn).
If you want to keep an axes pinned to a specific place, e.g., the edge of the graph, set up a floating axis. Otherwise make sure the orthogonal coordinate is set (it defaults to 0). For example, the orthogonal coordinate for the x-axis is the y-value where the x-axis crosses the y-axis.