sg.Text('First Read:', font=("Times New Roman", 9)),
sg.Input(key='-first_read-', size=(25, 1), default_text='0,0,0', justification='center', font=("Times New Roman", 9), expand_x=True),
sg.Text('Second Read:', font=("Times New Roman", 9)),
sg.Input(key='-second_read-', size=(25, 1), default_text='0,0,0', justification='center', font=("Times New Roman", 9), expand_x=True),
data_list_first = value_fpr_plot["-first_read-"].split(',')
data_list_second = value_fpr_plot["-second_read-"].split(',')
plt.clf() # 清除当前图形的所有轴,通常用于在绘制新图形之前清除上一个图形。
colors = list(mcolors.XKCD_COLORS.keys())
marker = [".", "2", "x", "o", "*", "s", "3", "4", "+", "d"]
data_list = []
data_list.append(data_list_first)
data_list.append(data_list_second)
y_ticks = int(max([max(t) for t in data_list]))
x_ticks = range(0, len(data_list[0]) * 10, 10)
for i in range(len(data_list)):
plt.plot(x_ticks, data_list[i], lw=1, ls='-', c=mcolors.XKCD_COLORS[colors[i]], marker=".", alpha=0.9, label=read_legend[i])
plt.yticks(arange(0, y_ticks + 1, ceil(y_ticks / 15)), fontsize=7)
经过value_fpr_plot["-first_read-"].split(',')
解析的数据会变为[‘1’,‘2’,‘3’]的形式,列表中的数据已经由预期的int变为str形式,进而使用该数据画图导致yticks错乱。
plt.clf() # 清除当前图形的所有轴,通常用于在绘制新图形之前清除上一个图形。
colors = list(mcolors.XKCD_COLORS.keys())
marker = [".", "2", "x", "o", "*", "s", "3", "4", "+", "d"]
data_list = []
data_list.append([int(i) for i in data_list_first]) #修改
data_list.append([int(i) for i in data_list_second])#修改
y_ticks = int(max([max(t) for t in data_list]))
x_ticks = range(0, len(data_list[0]) * 10, 10)
for i in range(len(data_list)):
plt.plot(x_ticks, data_list[i], lw=1, ls='-', c=mcolors.XKCD_COLORS[colors[i]], marker=".", alpha=0.9, label=read_legend[i])
plt.yticks(arange(0, y_ticks + 1, ceil(y_ticks / 15)), fontsize=7)