![]() ![]() ![]() 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. 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())) Scatter plot the predicted values (ypred) with blue color and a line width of 5. 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()) Create a figure with a size of 15x10 using plt.figure(figsize(15,10)). You may use automatic aspect on the image ax.imshow(z, aspect="auto") It's not perfectly clear what your desired outcome is. We can adjust the size of the figure containing the subplots in the matplotlib by specifying a list of two values against the figsize parameter in the () function, where the 1st value specifies the width of the figure and the 2nd value specifies the height of the figure. I am using Python 2.7 and matplotlib 2.0.0 Answers Read: Matplotlib plot bar chart Matplotlib subplot figure size. 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 When trying this, the image appears smaller than the scatter plot. 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 |