使用Python绘制1:1对角线图,用于对数据进行比较。
Code:
import numpy as np import matplotlib.pyplot as plt x=[1,3,5,7,9] y=[2,5,9,3,7] fig,ax=plt.subplots(figsize=(5,5)) Axis_line=np.linspace(*ax.get_xlim(),2) ax.plot(Axis_line,Axis_line,transform=ax.transAxes,linestyle='--',linewidth=2,color='black',label="1:1 Line") ax.set_xlim([0,10]) ax.set_ylim([0,10]) ax.scatter(x,y,color='red') ax.legend() plt.show() plt.clf()
Result: