from bokeh.plotting import figure, show,output_file import numpy as np import pandas as pd import pandas df = pd.read_csv(r'/Users/fuchuanruo/Desktop/可视化作业/实践/train.csv')

创建房价的散点图

p1 = figure(title='Housing Scatter Plot', x_axis_label='OverallQual', y_axis_label='SalePrice') p1.scatter(df['OverallQual'], df['SalePrice'], size=5, color='blue')

创建贷款的柱状图

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))

Python Bokeh 可视化分析:房价和贷款数据

原文地址: https://www.cveoy.top/t/topic/jkoh 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录