对pandas的dataframe绘图并保存的实现方法

yipeiwu_com6年前Python基础

对dataframe绘图并保存:

ax = df.plot() 
fig = ax.get_figure()
fig.savefig('fig.png')

可以制定列,对该列各取值作统计:

label_dis = df.label.value_counts()
ax = label_dis.plot(title='label distribution', kind='bar', figsize=(18, 12))
fig = ax.get_figure()
fig.savefig('label_distribution.png')

以上这篇对pandas的dataframe绘图并保存的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

py2exe 编译ico图标的代码

复制代码 代码如下: #setup.py from distutils.core import setup import py2exe setup( # targets to build...

Pytorch之finetune使用详解

finetune分为全局finetune和局部finetune。首先介绍一下局部finetune步骤: 1.固定参数 for name, child in model.named...

Python Threading 线程/互斥锁/死锁/GIL锁

导入线程包 import threading 准备函数线程,传参数 t1 = threading.Thread(target=func,args=(args,)) 类继承线程,创建线程对...

在python 不同时区之间的差值与转换方法

之前有个程序,里面有个时间部分是按照国内时区,也就是东八区,来写的,程序中定义了北京时间2点到八点进行检查;后面程序在国外机器上,例如说韩国,欧美等,执行的时候发现会有时间上的问题,因为...

解决tensorflow由于未初始化变量而导致的错误问题

我写的这个程序 import tensorflow as tf sess=tf.InteractiveSession() x=tf.Variable([1.0,2.0]) a=tf...