How to resize subplots in pyplot, dependent on the height of a table? - matplotlib

There are many ways in matplotlib.pyplot to change the size of subplots. However, they all seem to require some hand-tuning. I would like to do it in an automatic way, depending on the actual sizes of the plots.
In my case, I would like to generate a whole lot of pdf files that look something like this:
As you can see, the table in the top subplot has a lot of white space around it, so I would like to reduce the vertical size of the top subplot and make the bottom one larger, to fill up the space a bit better.
I know that I can set the sizes of subplots with GridSpec, among a bewildering array of other methods. However, the number of rows in my tables will vary from file to file, so I don't know in advance what sizes I want the subplots to be.
TL;DR: I want the first subplot to be as tall as the table (however tall that is) and the second to take up the remaining space. Is this possible in MatPlotLib?

Related

Matplotlib: Grid is too tight for small plot

I want to make the plot smaller, so it can save some space in print. However, when I make it smaller, the grid will be too tight:
Honestly, I don't get it. Why can't matplotlib auto-detect that this image is too small that the lable should be with a bigger interval?
So, How can I make the grid more sparse, so the lables won't overlap with each other?
Additionally, the title will also collapse with the labels. I can set it manually, by plt.suptitle(title, y=1.08). So it will look better
But I'm wondering if there is anyway to do it automatically?
Note: I'm using seaborn, but I tried with pure matplotlib, same problem.

Matplotlib: align axes across different figures

I'm having two different figures with identical figsize which I embed in an latex ducment (picture).
How can I make that it does not missalign slightly in the way it currently is? (the right figure has larger axis)

How keep more white space on Y-Axis of Chart?

Goal
I want to display data into a chart control. Like so:
Current Problem
My issue is the data (blue line) goes out of the chart. As seen above, it seems as if my data exceeds the viewing pane... I'd like to be able to view the whole thing.
Is it possible to create some sort of padding? Keep in mind, not all values will be in percentage...
The solution I used is multiplying the YAxis maximum by 5%.
This creates a small padding over my maximum values which enables me to view it correctly. Not very elegant but it does the job for now.
Perhaps there are better answers but this worked great.

How can I extend a line from two points to the edges of the plot area using Core Plot?

I'm using Core Plot to graph linear equations.
I would like to be able to supply two different data points and have a line drawn between them, but also extrapolated beyond the points themselves so that the line extends all the way to the edges of the plot area.
For example, given a 20x20 plot area with the origin centered and points at -5,-5 and 5,5, the line (green below) would extend all the way from -10,10 to 10,10 (blue below).
Is this possible? Is the best option just to find the plot range (which will be different each time) and find two points that are outside of it? I'm not sure if this will work; I have user interaction enabled and I want to make sure that the user can't accidentally pan far enough that the line will end.
Your idea of finding two endpoints outside the plot range is what I'd do. If you've limited the scrolling range, just pick points at the limits of that range. If not, you'll need to monitor changes to the plot space ranges with a plot space delegate and update the plot as needed.

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.