How set a common title, common x label and set different y-axis?

I´m looking for a way to set a common title of a subplot (3 plots) and set different preferences in each axis label.
Well here is a figure of my actual plot:

If you can notice that the title “Selection Score for each Method” is repeated 3 times, I´m looking for a way to plot only one at the top of the subplot.
Another issue is that I choose the option sharey=False, so I want to set a different y-label for each plot. For example, here the y-label for each plot:
plot 1:SLAC
plot 2: FEL
plot 3: MEME
However, in the figure when I tried to set y-label, only appear in the last plot.
Here is the complete script if anyone needs it.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import (AutoMinorLocator, MultipleLocator)
# Set the style of the plot
plt.style.use("seaborn")
# Set the data for each method (SLAC, FEL and MEME)
data_SLAC = pd.read_csv("S_SLAC.csv")
dN_SLAC = data_SLAC["dN"]
dS_SLAC = data_SLAC["dS"]
Omega_SLAC = data_SLAC["P [dN/dS > 1]"]

data_FEL = pd.read_csv("S_FEL.csv")
dN_FEL = data_FEL["beta"]
dS_FEL = data_FEL["alpha"]
Omega_FEL = data_FEL["omega"]

data_MEME = pd.read_csv("S_MEME.csv")
dN_MEME = data_MEME["&beta"]
dS_MEME = data_MEME["&alpha"]
Omega_MEME_positive = data_MEME["&beta+"]
Omega_MEME_neutral = data_MEME["&beta-"]
# Set the parameters of the subplot
fig, axs = plt.subplots(3,1, sharex=True, sharey=False, figsize=(16,5))
#ax.plot(dN, label="dN")
#ax.plot(dS, label="dS")
axs[0].plot(Omega_SLAC, label="dN/dS > 1")
axs[1].plot(Omega_FEL, label="dN/dS > 1")
axs[2].plot(Omega_MEME_positive, label="dN/dS > 1")
# Set the range of values in x-axis
for ax in axs:
    ax.xaxis.set_major_locator(MultipleLocator(50))

### HERE is the line of concern for the post
# Set title of each subplot
for ax1 in axs:
    ax1.set_title("Selection Score for each Method")
    ax.set(xlabel='Amino Acid Position', ylabel='Selection Score')
# Fix the distribution of each plot
plt.tight_layout()
plt.plot()

Any suggestion is welcome!
Thank!

axs is a numpy array, so axs[0].set_title('Boo') will just set the title of the first axes. If you want to set the ylabel for all the axes just do ax.set_ylabel('The label'), and change it for each axes.

1 Like

Great! Thank for your replay and your idea!

Here the script edited after the idea of a user!

# Set the style of the plot
plt.style.use("seaborn")
# Set the data for each method (SLAC, FEL and MEME)
data_SLAC = pd.read_csv("S_SLAC.csv")
dN_SLAC = data_SLAC["dN"]
dS_SLAC = data_SLAC["dS"]
Omega_SLAC = data_SLAC["P [dN/dS > 1]"]

data_FEL = pd.read_csv("S_FEL.csv")
dN_FEL = data_FEL["beta"]
dS_FEL = data_FEL["alpha"]
Omega_FEL = data_FEL["omega"]

data_MEME = pd.read_csv("S_MEME.csv")
dN_MEME = data_MEME["&beta"]
dS_MEME = data_MEME["&alpha"]
Omega_MEME_positive = data_MEME["&beta+"]
Omega_MEME_neutral = data_MEME["&beta-"]
# Set the parameters of the subplot
fig, axs = plt.subplots(3,1, sharex=True, sharey=False, figsize=(16,5))
#ax.plot(dN, label="dN")
#ax.plot(dS, label="dS")
axs[0].plot(Omega_SLAC, label="dN/dS > 1")
axs[1].plot(Omega_FEL, label="dN/dS > 1")
axs[2].plot(Omega_MEME_positive, label="dN/dS > 1")
# Set the range of values in x-axis
for ax in axs:
    ax.xaxis.set_major_locator(MultipleLocator(50))
# Set title and label of each subplot
axs[0].set_title("Selection Score for each Method")
ax.set(xlabel='Amino Acid Position')
axs[0].set(ylabel="SLAC")
axs[1].set(ylabel="FEL")
axs[2].set(ylabel="MEME")
# Fix the distribution of each plot
plt.tight_layout()
plt.plot()