Matplotlib: Subplots




[ad_1]

Code:

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

fig, ax = plt.subplots(3, 2, sharey=True, figsize=(7,10),
dpi=500)
x = np.arange(0,10,0.1)
y = np.sin(x)

ax[0,1].plot(x,y, label=’sin(x)’)

ax[1,0].plot(x,y, label=’sin(x)’)
ax[1,0].plot(x,2*y, label=’2*sin(x)’)

# remove tick labels
ax[0,0].set_xticklabels([])
# ax[0,0].set_xticks([])

# ax[0,0].set_ylabel(“y axis of [0,0]”)
# ax[0,0].set_xlabel(“x axis of [0,0]”)

ax[1,0].legend(loc=1)

fig.text(0.05, 0.5, “sin(y)”, rotation=’vertical’, fontsize=18)

fig.text(0.5, 0.08, “x”, rotation=’horizontal’, fontsize=18)

plt.subplots_adjust(wspace=.2, hspace=.3)

Source


[ad_2]

One Comment

  • Gihan Panapitiya
    January 15, 2021

    💜️💜️💜️

Write a comment