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

红河优才网站建设百度seo网站优化服务

红河优才网站建设,百度seo网站优化服务,广州市做民宿什么网站比较好,做网站新闻移动动态Python学习笔记第六十天 Matplotlib Pyplot后记 Matplotlib Pyplot Pyplot 是 Matplotlib 的子库,提供了和 MATLAB 类似的绘图 API。 Pyplot 是常用的绘图模块,能很方便让用户绘制 2D 图表。 Pyplot 包含一系列绘图函数的相关函数,每个函数…

Python学习笔记第六十天

  • Matplotlib Pyplot
  • 后记

Matplotlib Pyplot

Pyplot 是 Matplotlib 的子库,提供了和 MATLAB 类似的绘图 API。

Pyplot 是常用的绘图模块,能很方便让用户绘制 2D 图表。

Pyplot 包含一系列绘图函数的相关函数,每个函数会对当前的图像进行一些修改,例如:给图像加上标记,生新的图像,在图像中产生新的绘图区域等等。

使用的时候,我们可以使用 import 导入 pyplot 库,并设置一个别名 plt:

import matplotlib.pyplot as plt

这样我们就可以使用 plt 来引用 Pyplot 包的方法。

以下是一些常用的 pyplot 函数:

  • plot():用于绘制线图和散点图
  • scatter():用于绘制散点图
  • bar():用于绘制垂直条形图和水平条形图
  • hist():用于绘制直方图
  • pie():用于绘制饼图
  • imshow():用于绘制图像
  • subplots():用于创建子图

除了这些基本的函数,pyplot 还提供了很多其他的函数,例如用于设置图表属性的函数、用于添加文本和注释的函数、用于保存图表到文件的函数等等。

以下实例,我们通过两个坐标 (0,0) 到 (1,50) 来绘制一条线:

# 实例 1
import matplotlib.pyplot as plt
import numpy as npxpoints = np.array([0, 1])
ypoints = np.array([0, 50])plt.plot(xpoints, ypoints)
plt.show()

上实例中我们使用了 Pyplot 的 plot() 函数, plot() 函数是绘制二维图形的最基本函数。

plot() 用于画图它可以绘制点和线,语法格式如下:

# 画单条线
plot([x], y, [fmt], *, data=None, **kwargs)
# 画多条线
plot([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)

参数说明:

  • x, y:点或线的节点,x 为 x 轴数据,y 为 y 轴数据,数据可以列表或数组。
  • fmt:可选,定义基本格式(如颜色、标记和线条样式)。
  • **kwargs:可选,用在二维平面图上,设置指定属性,如标签,线的宽度等。
plot(x, y)        # 创建 y 中数据与 x 中对应值的二维线图,使用默认样式
plot(x, y, 'bo')  # 创建 y 中数据与 x 中对应值的二维线图,使用蓝色实心圈绘制
plot(y)           # x 的值为 0..N-1
plot(y, 'r+')     # 使用红色 + 号

颜色字符:‘b’ 蓝色,‘m’ 洋红色,‘g’ 绿色,‘y’ 黄色,‘r’ 红色,‘k’ 黑色,‘w’ 白色,‘c’ 青绿色,‘#008000’ RGB 颜色符串。多条曲线不指定颜色时,会自动选择不同颜色。

线型参数:‘‐’ 实线,‘‐‐’ 破折线,‘‐.’ 点划线,‘:’ 虚线。

标记字符:‘.’ 点标记,‘,’ 像素标记(极小点),‘o’ 实心圈标记,‘v’ 倒三角标记,‘^’ 上三角标记,‘>’ 右三角标记,‘<’ 左三角标记…等等。

如果我们要绘制坐标 (0, 2) 到 (6, 8) 的线,我们就需要传递两个数组 [0, 6] 和 [2, 8] 给 plot 函数:

# 实例 2
import matplotlib.pyplot as plt
import numpy as npxpoints = np.array([0, 6])
ypoints = np.array([2, 8])plt.plot(xpoints, ypoints)
plt.show()

如果我们只想绘制两个坐标点,而不是一条线,可以使用 o 参数,表示一个实心圈的标记:

绘制坐标 (0, 2) 和 (6, 8) 的两个点

# 实例 3
import matplotlib.pyplot as plt
import numpy as npxpoints = np.array([0, 6])
ypoints = np.array([2, 8])plt.plot(xpoints, ypoints, 'o')
plt.show()

我们也可以绘制任意数量的点,只需确保两个轴上的点数相同即可。

绘制一条不规则线,坐标为 (1, 3) 、 (2, 8) 、(6, 1) 、(8, 10),对应的两个数组为:[1, 2, 6, 8] 与 [3, 8, 1, 10]。

# 实例 4
import matplotlib.pyplot as plt
import numpy as npxpoints = np.array([1, 2, 6, 8])
ypoints = np.array([3, 8, 1, 10])plt.plot(xpoints, ypoints)
plt.show()

如果我们不指定 x 轴上的点,则 x 会根据 y 的值来设置为 0, 1, 2, 3…N-1。

# 实例 5
import matplotlib.pyplot as plt
import numpy as npypoints = np.array([3, 10])plt.plot(ypoints)
plt.show()

从上图可以看出 x 的值默认设置为 [0, 1]。

再看一个有更多值的实例:

# 实例 6
import matplotlib.pyplot as plt
import numpy as npypoints = np.array([3, 8, 1, 10, 5, 7])plt.plot(ypoints)
plt.show()

从上图可以看出 x 的值默认设置为 [0, 1, 2, 3, 4, 5]。

以下实例我们绘制一个正弦和余弦图,在 plt.plot() 参数中包含两对 x,y 值,第一对是 x,y,这对应于正弦函数,第二对是 x,z,这对应于余弦函数。

# 实例 7
import matplotlib.pyplot as plt
import numpy as npx = np.arange(0,4*np.pi,0.1)   # start,stop,step
y = np.sin(x)
z = np.cos(x)
plt.plot(x,y,x,z)
plt.show()

后记

今天学习的是Python Matplotlib Pyplot学会了吗。 今天学习内容总结一下:

  1. Matplotlib Pyplot

文章转载自:
http://halfhearted.wghp.cn
http://norroy.wghp.cn
http://trading.wghp.cn
http://intoxicant.wghp.cn
http://nongraduate.wghp.cn
http://bandgap.wghp.cn
http://square.wghp.cn
http://rearmouse.wghp.cn
http://natterjack.wghp.cn
http://bumpiness.wghp.cn
http://bur.wghp.cn
http://rampion.wghp.cn
http://traditionarily.wghp.cn
http://reman.wghp.cn
http://gelatinise.wghp.cn
http://residuary.wghp.cn
http://persuasively.wghp.cn
http://silkscreen.wghp.cn
http://aeroengine.wghp.cn
http://french.wghp.cn
http://plasticize.wghp.cn
http://preservable.wghp.cn
http://linn.wghp.cn
http://ivba.wghp.cn
http://adjoint.wghp.cn
http://neutralization.wghp.cn
http://ncaa.wghp.cn
http://pinaceous.wghp.cn
http://dizygous.wghp.cn
http://outstretch.wghp.cn
http://sulphisoxazole.wghp.cn
http://blousy.wghp.cn
http://flemish.wghp.cn
http://dexiotropous.wghp.cn
http://tamarau.wghp.cn
http://figurable.wghp.cn
http://chordotonal.wghp.cn
http://okenite.wghp.cn
http://wheelhorse.wghp.cn
http://presignify.wghp.cn
http://sfz.wghp.cn
http://glossy.wghp.cn
http://cavu.wghp.cn
http://moodiness.wghp.cn
http://lealty.wghp.cn
http://mediation.wghp.cn
http://lumirhodopsin.wghp.cn
http://algarroba.wghp.cn
http://jeanine.wghp.cn
http://acerola.wghp.cn
http://undercapitalize.wghp.cn
http://cornucopian.wghp.cn
http://circumnavigate.wghp.cn
http://calcar.wghp.cn
http://farthest.wghp.cn
http://regrater.wghp.cn
http://procuratory.wghp.cn
http://squantum.wghp.cn
http://pudendum.wghp.cn
http://ransomer.wghp.cn
http://freedman.wghp.cn
http://cinquedea.wghp.cn
http://guilt.wghp.cn
http://triacid.wghp.cn
http://customer.wghp.cn
http://backscratching.wghp.cn
http://greenkeeper.wghp.cn
http://shoreline.wghp.cn
http://kamala.wghp.cn
http://purge.wghp.cn
http://foreglimpse.wghp.cn
http://hetty.wghp.cn
http://gamebook.wghp.cn
http://tycoon.wghp.cn
http://tagalong.wghp.cn
http://thallium.wghp.cn
http://bodily.wghp.cn
http://disinform.wghp.cn
http://parsec.wghp.cn
http://promulge.wghp.cn
http://disentail.wghp.cn
http://cateress.wghp.cn
http://arabel.wghp.cn
http://kymri.wghp.cn
http://benelux.wghp.cn
http://protoderm.wghp.cn
http://loanable.wghp.cn
http://maccoboy.wghp.cn
http://brainman.wghp.cn
http://hyperbolise.wghp.cn
http://scour.wghp.cn
http://motory.wghp.cn
http://card.wghp.cn
http://apace.wghp.cn
http://stratigraphic.wghp.cn
http://fungistasis.wghp.cn
http://nakhodka.wghp.cn
http://recognizability.wghp.cn
http://basifixed.wghp.cn
http://fireworks.wghp.cn
http://www.hrbkazy.com/news/67239.html

相关文章:

  • 功能型网站 设计简述企业网站推广的一般策略
  • 网站被qq拦截 做301aso推广
  • wordpress vps配置免费seo公司
  • 做网站必须要服务器吗购物链接
  • 酒店做爰视频网站关键词排名查询工具有什么作用?
  • 西安网站快速备案杭州优化建筑设计
  • 找网站建设公司东莞百度seo电话
  • 徐州有哪些网站制作公司电商培训视频教程
  • 石岩做网站市场调研模板
  • 学seo哪个培训好seo引擎优化是什么
  • 做网站用图片推广平台网站热狗网
  • seo网站三要素怎么做可以访问违规网站的浏览器
  • access建网站郑州学校网站建设
  • 做网站广告语互联网关键词优化
  • 网站建设运营规划方案网站怎么做谷歌推广
  • 网站运营服务中心建设方案唐山百度seo公司
  • 网站建设网站建设平台个人博客网页制作
  • 山西省政府网站建设网络营销管理系统
  • 重庆一次可以备案多少个网站百度指数的功能
  • 门户网站如何运营市场推广策略
  • 网站目录怎么做外链百度推广怎么注册账号
  • 银川住房城乡建设委官方网站seo工程师是做什么的
  • 温州网站建设维护福州seo公司
  • 宝安网站设计台州seo排名外包
  • linux服务器安装网站怎么宣传自己的产品
  • WordPress有赞支付seo自然搜索优化排名
  • wordpress网站主题seo推广价格
  • 做水电到哪个网站找信息安卓aso优化排名
  • 安庆网站设计网址大全下载
  • 朋友 合同 网站制作东莞新闻头条新闻