本文主要是介绍Python 数据可视化 散点图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Python 数据可视化 散点图
import matplotlib.pyplot as plt
import numpy as npdef plot_scatter(ref_info_dict, test_info_dict):# 绘制散点图,ref横,test纵plt.figure(figsize=(80, 48))n = 0# scatter_header_list = ['peak_insert_size', 'median_insert_size']scatter_header_list = list(ref_info_dict.keys())for header in scatter_header_list:n += 1plt.subplot(8, 10, n)x = np.array(ref_info_dict[header])y = np.array(test_info_dict[header])max_line = max([max(x), max(y)])min_line = min([min(x), min(y)])plt.scatter(x, # 横坐标y, # 纵坐标c='red', # 点的颜色label='function') # 标签 即为点代表的意思plt.plot([min_line, max_line], [min_line, max_line], ls="--", c=".3")plt.title(header)plt.xlabel("old data")plt.ylabel("new data")# 3.展示图形plt.legend() # 显示图例plt.show() # 显示所绘图形plt.savefig('tmp_scatter.jpg')
这篇关于Python 数据可视化 散点图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!