How to make two plots side-by-side

Change your subplot settings to: plt.subplot(1, 2, 1) … plt.subplot(1, 2, 2) The parameters for subplot are: number of rows, number of columns, and which subplot you’re currently on. So 1, 2, 1 means “a 1-row, 2-column figure: go to the first subplot.” Then 1, 2, 2 means “a 1-row, 2-column figure: go to the … Read more

Matplotlib – global legend and title aside subplots

Global title: In newer releases of matplotlib one can use Figure.suptitle() method of Figure: import matplotlib.pyplot as plt fig = plt.gcf() fig.suptitle(“Title centered above all subplots”, fontsize=14) Alternatively (based on @Steven C. Howell’s comment below (thank you!)), use the matplotlib.pyplot.suptitle() function: import matplotlib.pyplot as plt # plot stuff # … plt.suptitle(“Title centered above all subplots”, … Read more

How to plot multiple dataframes in subplots

You can manually create the subplots with matplotlib, and then plot the dataframes on a specific subplot using the ax keyword. For example for 4 subplots (2×2): import matplotlib.pyplot as plt fig, axes = plt.subplots(nrows=2, ncols=2) df1.plot(ax=axes[0,0]) df2.plot(ax=axes[0,1]) … Here axes is an array which holds the different subplot axes, and you can access one … Read more

How to set the subplot axis range

You have pylab.ylim: pylab.ylim([0,1000]) Note: The command has to be executed after the plot! Update 2021 Since the use of pylab is now strongly discouraged by matplotlib, you should instead use pyplot: from matplotlib import pyplot as plt plt.ylim(0, 100) #corresponding function for the x-axis plt.xlim(1, 1000)

How to have one colorbar for all subplots

Just place the colorbar in its own axis and use subplots_adjust to make room for it. As a quick example: import numpy as np import matplotlib.pyplot as plt fig, axes = plt.subplots(nrows=2, ncols=2) for ax in axes.flat: im = ax.imshow(np.random.random((10,10)), vmin=0, vmax=1) fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7]) fig.colorbar(im, cax=cbar_ax) plt.show() Note that the … Read more

Matplotlib different size subplots

Another way is to use the subplots function and pass the width ratio with gridspec_kw matplotlib Tutorial: Customizing Figure Layouts Using GridSpec and Other Functions matplotlib.gridspec.GridSpec has available gridspect_kw options import numpy as np import matplotlib.pyplot as plt # generate some data x = np.arange(0, 10, 0.2) y = np.sin(x) # plot it f, (a0, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)