![]() ![]() If you want to use mpl_toolkits and make your hands dirty, this answer would be a good read. This answer for using the subplot parameters to achieve a certain aspect. rng.size)) > yrs 1950 + rng > fig, ax plt.subplots(figsize(5. 1 Answer Sorted by: 30 Just switch figure size width and height from: fig plt.figure (figsize (20, 8)) to: fig plt.figure (figsize (8, 20)) to use the whole page for your plots. If the image does not have equal limits (is not square), one still needs to divide by the aspect of the image: asp = np.diff(ax2.get_xlim()) / np.diff(ax2.get_ylim())Īsp /= np.abs(np.diff(ax1.get_xlim()) / np.diff(ax1.get_ylim())) However, matplotlib is also a massive library, and getting a plot to look just. Or you may set the aspect of the line plot depending on its axis limits such that it gets the same size as the image (in case the image has equal x and y sizes) asp = np.diff(ax2.get_xlim()) / np.diff(ax2.get_ylim())Īsp = np.diff(ax2.get_xlim()) / np.diff(ax2.get_ylim()) You may use automatic aspect on the image ax.imshow(z, aspect="auto") It's not perfectly clear what your desired outcome is. I am using Python 2.7 and matplotlib 2.0.0 Answers Is there a way to make imshow and a scatter plot appear the same size in a figure without manually changing the axes sizes? I have also tried to adjust the subplot sizes manually by using: fig = plt.figure()īy trial and error I can get the two subplots to the correct size, though any change in the overall figure size will mean that the subplots will no longer be the same size. I have tried using gridspec as shown in this answer: fig=plt.figure()īut this gives the same result. How can I get the two sublpots to have the same height? (and width I suppose) Small example code is shown below: import matplotlib.pyplot as plt Scatter plot the predicted values (ypred) with blue color and a line width of 5. When trying this, the image appears smaller than the scatter plot. Create a figure with a size of 15x10 using plt.figure(figsize(15,10)). I am trying to plot an image (using matplotlib.imshow) and a scatter plot within the same figure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |