(Python Note) 11 对角线图

2022/3/19 22:30:32

本文主要是介绍(Python Note) 11 对角线图,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

使用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:



这篇关于(Python Note) 11 对角线图的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程