使用python的bokeh库对housing和loan进行可视化分析布局合理from bokehplotting import figure showoutput_fileimport numpy as npimport pandas as pdimport pandasdf = pdread_csvrUsersfuchuanruoDesktop可视化作业实践traincsv
创建housing的散点图
p1 = figure(title="Housing Scatter Plot", x_axis_label='OverallQual', y_axis_label='SalePrice') p1.scatter(df['OverallQual'], df['SalePrice'], size=5, color="blue")
创建loan的柱状图
p2 = figure(title="Loan Bar Plot", x_axis_label='LoanAmount', y_axis_label='Frequency') hist, edges = np.histogram(df['LoanAmount'], bins=50) p2.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:], fill_color="orange", line_color="white")
将两个图形合并到一个布局中
layout = [[p1, p2]] output_file("housing_loan_analysis.html") show(pandas.layouts.Column(layout)
原文地址: https://www.cveoy.top/t/topic/fdo8 著作权归作者所有。请勿转载和采集!