当前位置: 首页 > news >正文

b2c 网站天津seo推广

b2c 网站,天津seo推广,济南做网站公司,网站建设南京公司网站建设文章目录 基础图误差线三维图等高线图场图统计图非结构坐标图 基础图 下面这8种图像一般只有两组坐标,直观容易理解。 函数坐标参数图形类别plotx,y曲线图stackplotx,y散点图stemx,y茎叶图scatterx,y散点图polarx,y极坐标图stepx,y步阶图barx,y条形图barhx,y横向条…

文章目录

    • 基础图
    • 误差线
    • 三维图
    • 等高线图
    • 场图
    • 统计图
    • 非结构坐标图

基础图

下面这8种图像一般只有两组坐标,直观容易理解。

函数坐标参数图形类别
plotx,y曲线图
stackplotx,y散点图
stemx,y茎叶图
scatterx,y散点图
polarx,y极坐标图
stepx,y步阶图
barx,y条形图
barhx,y横向条形图

其中,除了极坐标需要添加一个极坐标映射之外,其他函数均在直角坐标系中绘制,效果如下

在这里插入图片描述

绘图代码如下

import matplotlib.pyplot as plt
import numpy as npx = np.arange(25)/3
y = np.sin(x)fDct = {"plot" : plt.plot,  "stackplot": plt.stackplot,"stem" : plt.stem,  "scatter"  : plt.scatter,         "polar": plt.polar, "step"     : plt.step, "bar"  : plt.bar,   "barh"     : plt.barh, }fig = plt.figure(figsize=(14,6))
for i,key in enumerate(fDct, 1):p = "polar" if key=="polar" else Noneax = fig.add_subplot(2,4,i, projection=p)fDct[key](x, y)plt.title(key)plt.tight_layout()
plt.show()

误差线

实际绘图时,误差线这种需求十分常见,尤其是在做拟合的时候,除了要画出趋势线之外,还可能要画出其抖动的范围,下面三种函数主要实现这个功能。

函数坐标图形类别
errorbarx,y,xerr,yerr误差线
fill_betweenx,y1,y2纵向区间图
fill_betweenxy, x1, x2横向区间图

图像效果为

在这里插入图片描述

绘图代码如下,errorbar函数的误差方向,与输入的参数有关。

x = np.arange(25)/3
y = np.sin(x)
y1, y2 = 0.9*y, 1.1*y
x1, x2 = 0.9*x, 1.1*x
xerr = np.abs([x1, x2])/10
yerr = np.abs([y1, y2])/10fig = plt.figure(figsize=(12,6))ax = fig.add_subplot(221)
ax.errorbar(x, y, yerr=yerr)
plt.title("errorbar with yerr")ax = fig.add_subplot(222)
ax.errorbar(x, y, xerr=xerr)
plt.title("errorbar with xerr")ax = fig.add_subplot(223)
ax.fill_between(x, y1, y2)
plt.title("fill_between")ax = fig.add_subplot(224)
ax.fill_betweenx(y, x1, x2)
plt.title("fill_betweenx")plt.tight_layout()
plt.show()

三维图

绘图函数坐标绘图类型坐标说明
plotx,y,z三维曲线图
scatterx,y,z三维散点图
plot_surfacex,y,z三维曲面图x,y必须是网格
plot_wireframex,y,z三维网格图x,y必须是网格
plot_trisurfx,y,z三角曲面图x,y,z是一维数组

plot和scatter虽然是二维绘图函数,但如果新增一个三维坐标,就可以摇身一变,成为三维曲线图或者三维散点图

在这里插入图片描述
绘图代码如下

x = np.arange(100)/10
y,z = np.sin(x), np.cos(x)fig = plt.figure(figsize=(8,4))ax = fig.add_subplot(121, projection='3d')
ax.plot(x,y,z)
plt.title("plot")ax = fig.add_subplot(122, projection='3d')
ax.scatter(x,y,z)
plt.title("scatter")plt.tight_layout()
plt.show()

真正专业的三维图是plot_surface, plot_wireframe和plot_trisurf

在这里插入图片描述

如果仔细看就会发现plot_trisurf的纹理和前两者不同,相比之下,前两者必须要求输入规整的数据。绘图代码如下

X, Y = np.indices([30, 30])/3 - 5
Z = np.sin(np.sqrt(X**2 + Y**2))fig = plt.figure(figsize=(12,5))ax = fig.add_subplot(131, projection='3d')
ax.plot_surface(X, Y, Z)
plt.title("plot_surface")ax = fig.add_subplot(132, projection='3d')
ax.plot_wireframe(X, Y, Z)
plt.title("plot_wireframe")ax = fig.add_subplot(133, projection='3d')
ax.plot_trisurf(X.reshape(-1), Y.reshape(-1), Z.reshape(-1))
plt.title("plot_trisurf")plt.tight_layout()
plt.show()

等高线图

绘图函数坐标说明
contour[x,y,]z等高线
contourf[x,y,]z填充等高线
pcolormesh[x,y,]z伪彩图
imshowz图像

其中,imshow就是正常的图片展示函数,这几个函数可以只指定z轴然后绘图

X, Y = np.indices([100,100])/30 - 1.5
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)fDct = {"contour": plt.contour, "contourf":plt.contourf, "pcolormesh" : plt.pcolormesh, "imshow":plt.imshow}fig = plt.figure(figsize=(9,6))
for i,key in enumerate(fDct, 1):ax = fig.add_subplot(2,2,i)fDct[key](Z)plt.title(key)plt.tight_layout()
plt.show()

绘图结果如下

在这里插入图片描述
可以看到,imshow和另外三种函数的区别是,其横坐标和纵坐标之间的比例始终是1:1,并不随着图像的拉伸而放大或者缩小。

除了imshow之外,另外三种函数还支持输入x,y,z三个坐标轴的数据来绘图,效果如下

在这里插入图片描述
绘图代码如下

X, Y = np.indices([100,100])/30 - 1.5
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)fDct = {"contour": plt.contour, "contourf":plt.contourf, "pcolormesh" : plt.pcolormesh}fig = plt.figure(figsize=(9,3))
for i,key in enumerate(fDct, 1):ax = fig.add_subplot(1,3,i)fDct[key](X,Y,Z)plt.title(key)plt.tight_layout()
plt.show()

场图

绘图函数坐标说明
quiverx,y,u,v向量场图
streamplotx,y,u,v流场图
barbsx,y,u,v风场图

quiver以单点为单位,绘制出某点处向量的方向;streamplot则在此之上,将每个点衔接到一起,显得更加有流动性;barbs则是以风向标志取代了向量,这个图过于专业,我应该没啥机会用到。

Y, X = np.indices([6,6])/0.75 - 4
U = X + Y
V = Y - Xdct = {"quiver":plt.quiver, "streamplot":plt.streamplot, "barbs" :plt.barbs}fig = plt.figure(figsize=(12,4))for i,key in enumerate(dct, 1):ax = fig.add_subplot(1,3,i)dct[key](X,Y,U,V)plt.title(key)plt.tight_layout()
plt.show()

在这里插入图片描述

统计图

绘图函数坐标说明
histx数据直方图
boxplotx箱线图
violinplotx小提琴图
enventplotx平行线疏密图
hist2dx,y二维直方图
hexbinx,y钻石图
piex饼图

其中hist, boxplot, violinplot, enventplot是统计一维数据的,可直接输入随机数,绘图函数会自行统计其区间

在这里插入图片描述
绘图代码如下

x = np.random.standard_normal(size=1000)dct = {"hist"  : plt.hist, "violinplot" : plt.violinplot,"boxplot": plt.boxplot}fig = plt.figure(figsize=(10,6))
for i,key in enumerate(dct, 1):ax = fig.add_subplot(2,2,i)dct[key](x)plt.title(key)ax = fig.add_subplot(224)
ax.eventplot(x)
plt.title("eventplot")plt.tight_layout()
plt.show()

hist2d和hexbin用于统计二维数据,最终以图像的形式展示出来,二者在观感上的主要区别是,hist2d的“像素”是方形的,而hexbin则是六边形的。

在这里插入图片描述

绘图代码如下

x = np.random.randn(5000)
y = 1.2 * x + np.random.randn(5000) / 3fig = plt.figure(figsize=(10,5))ax = fig.add_subplot(121)
ax.hist2d(x, y, bins=[np.arange(-3,3,0.1)] * 2)
plt.title("hist2d")ax = fig.add_subplot(122)
ax.hexbin(x, y, gridsize=20)
plt.title("hexbin")plt.tight_layout()
plt.show()

最后还有一个饼图,饼图要求输入坐标必须都大于0,绘图代码如下

plt.pie([1,2,3,4,5])
plt.tight_layout()
plt.show()

在这里插入图片描述

非结构坐标图

下面这四个绘图函数有一个特点,即其绘图坐标并不是格式化的,而支持随机坐标进行绘图,这一点和plot_trisurf比较相似

绘图函数坐标说明
tricontourx,y,z非结构等高线
tricontourfx,y,z非结构化填充等高线
tricolorx,y,z非结构化伪彩图
triplotx,y三角连线图

在这里插入图片描述

绘图代码如下

x = np.random.uniform(-4, 4, 256)
y = np.random.uniform(-2, 2, 256)
z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)levels = np.linspace(z.min(), z.max(), 7)fig = plt.figure(figsize=(12,6))ax = fig.add_subplot(221)
ax.plot(x, y, 'o', markersize=1, color='lightgrey', alpha=0.5)
ax.tricontour(x, y, z, levels=levels)
plt.title("tricontour")ax = fig.add_subplot(222)
ax.plot(x, y, 'o', markersize=1, color='lightgrey', alpha=0.5)
ax.tricontourf(x, y, z, levels=levels)
plt.title("tricontourf")ax = fig.add_subplot(223)
ax.plot(x, y, 'o', markersize=1, color='lightgrey', alpha=0.5)
ax.tripcolor(x, y, z)
plt.title("tripcolor")ax = fig.add_subplot(224)
ax.triplot(x,y)
plt.title("triplot")plt.tight_layout()
plt.show()
http://www.hkea.cn/news/727243/

相关文章:

  • 网站不兼容ie6自助建站模板
  • 甘肃网站建设公司百中搜优化软件
  • 国内外贸网站建设公司seo教程 百度网盘
  • 一物一码二维码生成系统最好用的系统优化软件
  • 如何在大网站做外链镇江网站建站
  • 杭州网站建设公司导航短视频营销案例
  • 昆明做网站建设有哪些长尾关键词排名工具
  • 一女被多男做的视频网站网站seo系统
  • 网站建设 青海网站建设找哪家好
  • win7 网站配置优化方案官网电子版
  • 广州seo优化公司排名浙江seo博客
  • 全网推广的方式有哪些抖音seo推荐算法
  • 网站开发开源架构抖音营销软件
  • 自己做的网站能放到网上么青岛seo经理
  • 营业推广策划方案邵阳网站seo
  • 手机网站横向切换kol合作推广
  • 专门做超市海报的网站宁波seo咨询
  • 仿网站上的焦点图在线看seo网站
  • 做网站的业务员艾滋病阻断药有哪些
  • web集团网站建设广告投放平台有哪些
  • 大连做网站建设广告资源对接平台
  • 做网站怎么写工作日志泉州网站seo公司
  • wordpress外链站内打开搜索引擎是什么意思啊
  • 做论坛网站需要什么备案新站seo优化快速上排名
  • 动漫网站html百度网盘搜索
  • 怎么看一个网站什么语言做的宝鸡seo培训
  • 数据库网站建设公司他达拉非片
  • 英文商城网站建设搜索引擎营销的特点
  • 易优建站系统图片百度搜索
  • 网站开发不用框架web网站设计