Home > Back-end >  how to set x, y label individually for scatter plots created using for loop?
how to set x, y label individually for scatter plots created using for loop?

Time:10-08

I have 1 y variable and hundreds of X variables that I want to create scatter plots through a for loop. I have codes that allow me to generate the plots but I need x, y labels to be marked accordingly as well. how can I do this? Any help is appreciated.

here are the codes:

figures = []

for column in X_uni:
    f = plt.figure(figsize=(6,6))
    figures  = [f]  # This appends a figure f to the list of figures
    ax = plt.axes()
    ax.plot(X_uni[column], y_data, marker = 'o', ls='', ms = 3.0)

CodePudding user response:

Use

ax.set_xlabel(column)

in your for loop. And add a ylabel:

ax.set_ylabel("ylabel")
  • Related