缩放Matplotlib轴以避免重叠?

时间:2019-11-07 10:27:55

标签: python-3.x matplotlib

我有一个像这样的数据集:

diode_current = [-26.134375482240845, -23.81993843337275, -21.598783974135323, -19.387312929806978, -17.17761670173803, -14.974619711767085, -12.827174951346398, -10.992060994366225, -9.80241823222485, -9.096633620784948, -8.634080639969094]

diode_current_file = [-26.134375482251997, -23.81993843338156, -21.598783974141586, -19.38731292981065, -17.1776167017391, -14.974619711765584, -12.827174951342666, -10.992060994362129, -9.802418232222136, -9.096633620783285, -8.634080639968035]

source_v_file = [0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6000000000000001, 0.7000000000000001, 0.8, 0.9, 1.0, 1.1]

可以看出,只在小数点后第10位之后,二极管和二极管列表中的值有所不同。

我正在尝试使用以下代码绘制图形:

plt.plot(source_v_file, diode_current_file, label = "Plot for Provided Values")
plt.plot(source_v_file, diode_current, label = "Plot for Optimized/Calculated Values")
plt.xlabel("Voltages")
plt.ylabel("Log(Diode Current)")
plt.title("Voltages vs Diode Current (P2)")
plt.legend()
plt.show()

由于Y轴值相差1e-10,因此该图是重叠的。

我正在使用这段代码按轴缩放贴图绘制它,并通过stackoverflow上的一些贴图:

plt.plot(source_v_file, diode_current_file, label = "Plot for Provided Values")
plt.plot(source_v_file, diode_current, label = "Plot for Optimized/Calculated Values")
plt.xticks(source_v_file)
plt.yticks(diode_current)
plt.xlabel("Voltages")
plt.ylabel("Log(Diode Current)")
plt.title("Voltages vs Diode Current (P2)")
plt.legend()
plt.show()

我希望能够将Y轴缩放到这样的粒度,即可以看到两个图形不重叠。

除了我尝试过的没有给我带来好结果的方法以外,这里还能做什么?

0 个答案:

没有答案