0

enter image description here

There are much more information overlap in my figure, I want to make it more clear, how to modify my code?

df = pd.read_excel('biodye_24samples.xlsx', header=None)
x_coord =df.values[0, 1:] 
df_name = df.values[1:, 0]
df_val = df.values[1:,1:]


fig = plt.figure()
for i in range(1, 13):
    ax = fig.add_subplot(3, 4, i)  
    ax.plot(x_coord, df_val[2*i - 2,],'r', label='SCI') 
    ax.plot(x_coord, df_val[2*i - 1,],'b', label='SCE') 
    plt.xlabel('Wavelength(nm)', fontsize = 10)
    plt.ylabel('Reflectance', fontsize = 10)
    plt.legend()
    plt.title(df_name[2*i - 2], fontsize = 10)
plt.show()
4daJKong
  • 1,825
  • 9
  • 21

2 Answers2

2

Two recommendations:

  • fig.tight_layout() to fix the padding between and around the subplots.
  • Increase the figsize of the figure: fig = plt.figure(figsize=(...,...)), where the arguments are width and height in inches.
BigBen
  • 46,229
  • 7
  • 24
  • 40
1

Consider using constrained layout rather than tight_layout. https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html For simple things they are the same, but for more complex layouts constrained_layout usually works better.

Jody Klymak
  • 4,979
  • 2
  • 15
  • 31