def get_plot(x_plot, y_plot, column_span, title, x_axis_1, y_axis_1,
x_axis_2 = None, x_axis_3 = None,
y_axis_2 = None, y_axis_3 = None,
label_1 = None, label_2 = None, label_3 = None):
ax[x_plot][y_plot] = plt.subplot2grid((3, 3), (x_plot, y_plot), colspan = column_span)
if label_1 is None:
ax[x_plot][y_plot].plot(x_axis_1, y_axis_1, linewidth = 2, color = ([0.37, 0.23, 0.37]), marker = 'o')
else:
ax[x_plot][y_plot].plot(x_axis_1, y_axis_1, linewidth = 2, color = ([0.37, 0.23, 0.37]), label = label_1, marker = 'o')
if x_axis_2 is not None and y_axis_2 is not None and label_2 is not None:
ax[x_plot][y_plot].plot(x_axis_2, y_axis_2, linewidth = 2, color = ([0.44, 0.64, 0.69]), label = label_2, marker = 'o')
if title == ' sterillite' or title == 'Fennel seeds':
ax[x_plot][y_plot].set_ylim(0, 100)
ax[x_plot][y_plot].legend()
if x_axis_3 is not None and y_axis_3 is not None and label_3 is not None:
ax[x_plot][y_plot].plot(x_axis_3, y_axis_3, linewidth = 2, color = ([0.68, 0.74, 0.22]), label = label_3, marker = 'o')
ax[x_plot][y_plot].legend()
ax[x_plot][y_plot].set_xlim(xmin = 0.0)
ax[x_plot][y_plot].yaxis.set_tick_params(labelsize = 8)
ax[x_plot][y_plot].xaxis.set_tick_params(labelsize = 8)
ax[x_plot][y_plot].set_axisbelow(True)
ax[x_plot][y_plot].yaxis.grid(True)
ax[x_plot][y_plot].xaxis.grid(False)
ax[x_plot][y_plot].yaxis.set_major_formatter(FuncFormatter(format_y_tick_suffix))
ax[x_plot][y_plot].set_title(title, fontsize = 10, fontweight = "bold")
上面的代码是有效的,但它太复杂了,难以理解。有人可以建议我另一种写作方式吗?我是python新手,有人可以帮忙吗。