微信扫一扫打赏支持

随笔分类 -  2_Python库(numpy、pandas、matplotlib、sklearn等)

摘要:matplotlib绘图的核心原理讲解 一、总结 一句话总结: 一个figure(画布)有多个axes(坐标系),也就是子图,一个axes(坐标系)有多个axis(坐标轴),比如x轴y轴 1、matplotlib获取axes? axes1 = figure.add_subplot(2,1,1) 2、 阅读全文
posted @ 2020-07-31 10:01 范仁义 阅读(378) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 14、Animation 动画 一、总结 一句话总结: ani=animation.FuncAnimation(fig=fig,func=animate,frames=100,init_func=init,interval=20,blit=False) imp 阅读全文
posted @ 2020-07-31 06:32 范仁义 阅读(310) 评论(0) 推荐(0)
摘要:jupyter notebook matplotlib绘制动态图并显示在notebook中 一、总结 一句话总结: 引入pylab库,加上%pylab就可以画出动态库了:Using matplotlib backend: Qt5Agg from matplotlib import pylab %py 阅读全文
posted @ 2020-07-31 06:01 范仁义 阅读(3189) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 13、次坐标轴 一、总结 一句话总结: I、ax2=axl.twinx(); #Create a twin Axes sharing the xaxis II、axl.plot(x,y1,'g-'); ax2.plot(x,y2,'b--'); import 阅读全文
posted @ 2020-07-31 05:21 范仁义 阅读(149) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 12、图中图 一、总结 一句话总结: 主要是改变axis的位置:ax1=fig.add_axes([left,bottom,width,height]) # 小图1(主要是改变 left,bottom,width,height) left,bottom,wid 阅读全文
posted @ 2020-07-31 04:54 范仁义 阅读(325) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 11、Subplot 分格显示 一、总结 一句话总结: method 1:subplot2grid:axl=plt.subplot2grid((3,4),(0,0),colspan=4,rowspan=1) method 2:gridspec:gs=grids 阅读全文
posted @ 2020-07-31 03:29 范仁义 阅读(219) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 10、Subplot 多合一显示 一、总结 一句话总结: plt.subplot(2,2,1):分成2行2列,第1个图:也可以写成 plt.subplot(221) import matplotlib.pyplot as plt plt.figure() # 阅读全文
posted @ 2020-07-30 23:11 范仁义 阅读(135) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 9、3D数据 一、总结 一句话总结: 画3D图:ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap=plt.get_cmap('rainbow')) 画等高线图:ax.contourf(X,Y,Z,zdir='z',o 阅读全文
posted @ 2020-07-30 22:51 范仁义 阅读(98) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 8、image图片 一、总结 一句话总结: plt.imshow(data) 将数值转成颜色 plt.colorbar() 显示颜色基准条 data=np.random.uniform(0,1.0,9).reshape((3,3)) # plt.imshow( 阅读全文
posted @ 2020-07-30 22:27 范仁义 阅读(84) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 7、contours 等高线图 一、总结 一句话总结: A、将点放到网格(meshgrid)上面去:X,Y=np.meshgrid(x,y) B、填色:plt.contourf(X,Y,f(X,Y),8, alpha=0.75, cmap=plt.cm.hot 阅读全文
posted @ 2020-07-30 06:35 范仁义 阅读(159) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 6、Bar 柱状图 一、总结 一句话总结: 柱状图使用非常简单,就是bar方法:plt.bar(X,+Y1,facecolor="#9999ff",edgecolor="white") plt.bar(X,+Y1,facecolor="#9999ff",edg 阅读全文
posted @ 2020-07-30 05:54 范仁义 阅读(161) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 5、Annotation标注 一、总结 一句话总结: 1、plt的annotate方法添加标注,plt的text方法添加文本标注 2、虚线用plot方法画,scatter方法来标注点 # 添加标注 # 1、画虚线,也就是两个点 x0=1 y0=2*x0+1 # 阅读全文
posted @ 2020-07-30 05:01 范仁义 阅读(116) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 4、legend图例 一、总结 一句话总结: 画线中加label表示线的名字,调用legend方法即可显示图例 import matplotlib.pyplot as plt import numpy as np x=np.linspace(-3,3,50) 阅读全文
posted @ 2020-07-30 03:22 范仁义 阅读(99) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 3、移动坐标轴 一、总结 一句话总结: 1、get current axis:ax=plt.gca() 2、去掉右轴和上轴,比如去掉右轴:ax.spines['right'].set_color('none') 3、将bottom轴设置为x轴,将left轴设置 阅读全文
posted @ 2020-07-30 03:09 范仁义 阅读(128) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 2、设置x轴、y轴参数 一、总结 一句话总结: plt.xlim((-1,2)):相当于取x轴-1到2的位置 plt.xlabel("x"):设置x轴的文本 plt.xticks(np.linspace(-1,2,5)):替换x轴的标注 # 2、设置x轴 y轴 阅读全文
posted @ 2020-07-30 02:52 范仁义 阅读(263) 评论(0) 推荐(0)
摘要:matplotlib_200730系列 1、figure图像 一、总结 一句话总结: A、不同的figure就是不同的图片 B、figure下面的代码属于这个figure C、plt.figure(num=3, figsize=(8,5)),图像编号是3,图像大小为8,5 二、figure图像 博客 阅读全文
posted @ 2020-07-30 01:49 范仁义 阅读(199) 评论(0) 推荐(0)
摘要:Python机器学习库sklearn.model 一、总结 一句话总结: sklearn(scikit-learn)库的功能非常强大,可以解决Classification、Regression、Clustering、Dimensionality reduction等问题 1、train_test_s 阅读全文
posted @ 2020-07-25 15:20 范仁义 阅读(219) 评论(0) 推荐(0)
摘要:jupyter notebook常用快捷键 一、总结 一句话总结: Jupyter Notebook 有两种键盘输入模式。编辑模式(Enter 键启动),允许你往单元中键入代码或文本;这时的单元框线是绿色的。命令模式 (按键 Esc 开启),键盘输入运行程序命令;这时的单元框线是灰色。 1、Jupy 阅读全文
posted @ 2020-07-25 01:52 范仁义 阅读(539) 评论(0) 推荐(0)
摘要:np.vstack()和np.hstack() 一、总结 一句话总结: np.vstack():在竖直方向上堆叠 np.hstack():在水平方向上平铺 二、np.vstack()和np.hstack() 转自或参考:np.vstack()和np.hstack()https://blog.csdn 阅读全文
posted @ 2020-07-23 20:33 范仁义 阅读(808) 评论(0) 推荐(0)
摘要:用 Python 检验数据正态分布的几种方法 一、总结 一句话总结: scipy.stats.anderson(x, dist ='norm' ) 该方法是由 scipy.stats.kstest 改进而来的,可以做正态分布、指数分布、Logistic 分布、Gumbel 分布等多种分布检验。 sc 阅读全文
posted @ 2020-07-23 14:44 范仁义 阅读(3070) 评论(0) 推荐(0)