Python 绘图

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all" 

import numpy as np
import pandas as pd 
import matplotlib.pyplot as plt
import seaborn as sns

plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号

import warnings
warnings.filterwarnings("ignore")

np.set_printoptions(suppress=True)  # 设置numpy不以科学计数法保存和显示 


# pandas 可视化
for riqi in data_zc['日期'].unique():
    for checi in data_zc[data_zc['日期'] == riqi]['车次'].unique():
        dff1 = data_zc[(data_zc['日期'] == riqi) & (data_zc['车次'] == checi)]
        dff1.iloc[:, 3:-1].plot(kind='line', subplots=True, layout=(1, 5), sharex=False, sharey=False, fontsize=8, figsize=(16,3))
        plt.suptitle(f'{riqi}{checi} 车正常', fontsize = 20)
plt.show();


 
df2.iloc[:, 1:-1].plot(kind='line', subplots=True, layout=(1, 5), sharex=False, sharey=False, fontsize=8, figsize=(16,3));


plt.suptitle(sname, x=0.5, y=0.96, fontsize=18, color='k')
# 设置子图间距
plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=0.5)


# 预设风格
from matplotlib.pylab import style #自定义图表风格
style.use('ggplot')

 plt.xticks(new_data.index[::], rotation=40, horizontalalignment='right', fontsize=10)  # x轴刻度
 
from bokeh.layouts import column
from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource
from bokeh.transform import jitter
xs = sorted(cf.编号.unique())
 
# p1 = figure(width=1500, height=500, title="Years vs mpg without jittering")
# p1.xgrid.grid_line_color = None
# p1.xaxis.ticker = xs
# p1.scatter(x='编号', y='数据', size=2, alpha=0.4, source=cf)


p2 = figure(width=1500, height=500, title="Years vs mpg with jittering")
p2.xgrid.grid_line_color = None
p2.xaxis.ticker = xs
p2.scatter(x=jitter('编号', 0.8), y='数据', size=2, alpha=0.4, source=cf)
show(p2)
# show(column(p1, p2))
 

from bokeh.layouts import column
from bokeh.plotting import figure, show
from bokeh.sampledata.autompg import autompg
from bokeh.transform import jitter
autompg
years = sorted(autompg.yr.unique())

p1 = figure(width=600, height=300, title="Years vs mpg without jittering")
p1.xgrid.grid_line_color = None
p1.xaxis.ticker = years
p1.scatter(x='yr', y='displ', size=2, alpha=0.4, source=autompg)

p2 = figure(width=600, height=300, title="Years vs mpg with jittering")
p2.xgrid.grid_line_color = None
p2.xaxis.ticker = years
p2.scatter(x=jitter('yr', 0.4), y='displ', size=3, alpha=0.4, source=autompg)

show(column(p1, p2))


# 热力图绘制
import seaborn as sns
corr = data1.corr()
mask = np.zeros_like(corr)
mask[np.triu_indices_from(mask)] = True
plt.figure(figsize=(6, 6))
with sns.axes_style("white"):
    ax = sns.heatmap(corr, annot=True, mask=mask, square=True, cmap="YlGnBu")
 plt.show();


# 矩阵散点图绘制
sns.pairplot(data1, height=2)
sns.pairplot(data1,kind="reg",diag_kind="kde", height=2);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值