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

搜索引擎对网站推广的作用关键词com

搜索引擎对网站推广的作用,关键词com,怎么开一个做网站的工作室,学php动态网站开发好就业目录 绘制简单的折线图1.1 修改标签文字和线条粗细1.2 校正图形1.3 使用内置样式1.4 使用scatter()绘制散点图并设置样式1.5 使用scatter()绘制一系列点1.6 python循环自动计算数据1.7 自定义颜色1.8 使用颜色映射1.9 自动保存图表练习题 绘制简单的折线图 绘制一个简单折线图…

目录

  • 绘制简单的折线图
    • 1.1 修改标签文字和线条粗细
    • 1.2 校正图形
    • 1.3 使用内置样式
    • 1.4 使用scatter()绘制散点图并设置样式
    • 1.5 使用scatter()绘制一系列点
    • 1.6 python循环自动计算数据
    • 1.7 自定义颜色
    • 1.8 使用颜色映射
    • 1.9 自动保存图表
    • 练习题

绘制简单的折线图

绘制一个简单折线图,使用模块pyplopt,该模块中包含很多生成图表的函数。

  • subplot()函数: 在一张图片中绘制一个或者多个图表。变量fig表示画窗,ax即axex,代表画窗中创建的笛卡尔坐标区。

  • plot()方法: 尝试根据给定的数据以有意义的方式绘制图表。

  • plt.show()方法: 打开matplotlib查看器并显示绘制的图片。

import matplotlib as pltsquares = [1,4,9,16,25]
fig,ax = plt.subplots()
ax.plot(squares)plt.show()

在这里插入图片描述

1.1 修改标签文字和线条粗细

对图表进行标签的大小、线条粗细进行调整。

  • linewidth参数:绘制的线条粗细。
  • set_title()函数:给图表制定标题。
  • fontsize参数:指定图表中各种文字的大小。
  • tick_params() 函数 : 设置刻度的样式。其中指定的实参将影响x轴和y轴上的刻度(axes=‘both’ ),并将刻度标记的字号设置为14(labelsize=14)。

注:由于显示中文出现错误时的解决方案:

在代码中添加如下语句 —— 设置字体为:SimHei(黑体)
plt.rcParams[‘font.sans-serif’]=[‘SimHei’]

解决方案

import matplotlib.pyplot as pltplt.rcParams['font.sans-serif']=['SimHei']
squares = [1,4,9,16,25]
fig,ax = plt.subplots()
ax.plot(squares,linewidth=3)ax.set_title("平方数",fontsize = 24)
ax.set_xlabel('值',fontsize=14)
ax.set_ylabel('值的平方',fontsize=14)ax.tick_params(axis='both',labelsize=14)plt.show()

在这里插入图片描述

1.2 校正图形

可以看到图片中横轴x对应的平方数都是不准确的,因此需要对图片进行校正。

向plot() 提供一系列数时,它假设第一个数据点对应的坐标值为0,但这里第一个点对应的 值为1。为改变这种默认行为,可向plot() 同时提供输入值和输出值。

  • 设置plot函数的输入值为从1开始到5结束的列表,然后把输入输出列表同时传入函数中。
import matplotlib.pyplot as pltplt.rcParams['font.sans-serif']=['SimHei']
squares = [1,4,9,16,25]
input_values = [1,2,3,4,5]
fig,ax = plt.subplots()
ax.plot(input_values,squares,linewidth=3)ax.set_title("平方数",fontsize = 24)
ax.set_xlabel('值',fontsize=14)
ax.set_ylabel('值的平方',fontsize=14)ax.tick_params(axis='both',labelsize=14)plt.show()

在这里插入图片描述

1.3 使用内置样式

可以使用matplotlib中内置的图标样式进行图像的绘制,打印一下已有的样式类型:

print(plt.style.available)

[‘Solarize_Light2’, ‘_classic_test_patch’, ‘_mpl-gallery’, ‘_mpl-gallery-nogrid’, ‘bmh’, ‘classic’, ‘dark_background’, ‘fast’, ‘fivethirtyeight’, ‘ggplot’, ‘grayscale’, ‘seaborn-v0_8’, ‘seaborn-v0_8-bright’, ‘seaborn-v0_8-colorblind’, ‘seaborn-v0_8-dark’, ‘seaborn-v0_8-dark-palette’, ‘seaborn-v0_8-darkgrid’, ‘seaborn-v0_8-deep’, ‘seaborn-v0_8-muted’, ‘seaborn-v0_8-notebook’, ‘seaborn-v0_8-paper’, ‘seaborn-v0_8-pastel’, ‘seaborn-v0_8-poster’, ‘seaborn-v0_8-talk’, ‘seaborn-v0_8-ticks’, ‘seaborn-v0_8-white’, ‘seaborn-v0_8-whitegrid’, ‘tableau-colorblind10’]

import matplotlib.pyplot as plt
print(plt.style.available)
squares = [1,4,9,16,25]
input_values = [1,2,3,4,5]plt.style.use('seaborn-v0_8')fig,ax = plt.subplots()
ax.plot(input_values,squares,linewidth=3)ax.set_title("squares",fontsize = 24)
ax.set_xlabel('value',fontsize=14)
ax.set_ylabel('the square of value',fontsize=14)ax.tick_params(axis='both',labelsize=14)plt.show()

使用plt.style.use(‘seaborn-v0_8’)绘制的图像:

在这里插入图片描述

换了另一个样式:

在这里插入图片描述

1.4 使用scatter()绘制散点图并设置样式

绘制一个点:

import matplotlib.pyplot as pltplt.style.use('seaborn-v0_8')
fig,ax = plt.subplots()
ax.scatter(2,4)plt.show()

在这里插入图片描述
绘制样式:

import matplotlib.pyplot as pltplt.style.use('seaborn-v0_8')
fig,ax = plt.subplots()
ax.scatter(2,4)ax.set_title('squares',fontsize = 24)
ax.set_xlabel('value',fontsize = 14)
ax.set_ylabel('squares of value',fontsize = 14)ax.tick_params(axis='both',which='major',labelsize=14)
plt.show()

在这里插入图片描述

1.5 使用scatter()绘制一系列点

列表x_values 包含要计算平方值的数,列表y_values 包含前述数的平方值。

将这些列表传递给scatter() 时,Matplotlib依次从每个列表中读取一个值来绘制一个点。

要绘制的点的坐标分别为 (1, 1)、(2, 4)、(3, 9)、(4, 16)和(5, 25)

import matplotlib.pyplot as pltx_values = [1,2,3,4,5]
y_values = [1,4,9,16,25]plt.style.use('seaborn-v0_8')
fig,ax = plt.subplots()
ax.scatter(x_values,y_values,s=100)
ax.set_title('squares',fontsize = 24)
ax.set_xlabel('value',fontsize = 14)
ax.set_ylabel('squares of value',fontsize = 14)ax.tick_params(axis='both',which='major',labelsize=14)
plt.show()

在这里插入图片描述

1.6 python循环自动计算数据

为1000个点绘制代码,首先创建两个包含x和y值的列表,然后传给scatter方法。

方法axis()指定了每个坐标轴的取值范围,该方法要求提供四个值:x轴y轴的最小值和最大值。

import matplotlib.pyplot as pltx_values = range(1,1001)
y_values = [x**2 for x in x_values]
plt.style.use('seaborn-v0_8')
fig,ax = plt.subplots()ax.scatter(x_values,y_values,s=10)
ax.set_title('squares',fontsize = 24)
ax.set_xlabel('value',fontsize = 14)
ax.set_ylabel('squares of value',fontsize = 14)
ax.axis([0,1100,0,1100000])
plt.show()

在这里插入图片描述

1.7 自定义颜色

设置散点图数据点的颜色:

  1. 传递参数c,设置c的内容。
ax.scatter(x_value,y_value,c='red',s=10)
  1. 使用RGB自定义颜色,传递一个元组,其中包含三个0~1的小数值,分别表示红色、绿色和蓝色。
ax.scatter(x_values, y_values, c=(0, 0.8, 0), s=10)

在这里插入图片描述

1.8 使用颜色映射

**颜色映射 (colormap)**是一系列颜色,从起始颜色渐变到结束颜色。在可视化中,颜色映射用于突出数据的规律。可以用较浅的颜色来显示较小的值,并使用较深的颜色来显示较大的值。

模块pyplot 内置了一组颜色映射。要使用这些颜色映射,需要告诉pyplot 该如何设置数据集中每个点的颜色。下面演示了如何根据每个点的 值来设置其颜色。

ax.scatter(x_values,y_values,c=y_values,cmap=plt.cm.Blues,s=10)

在这里插入图片描述

1.9 自动保存图表

要让程序自动将图表保存到文件中,可将调用plt.show() 替换为调用plt.savefig()。

plt.savefig('squares_plot.png', bbox_inches='tight')
  • 第一个实参指定要以什么文件名保存图表,这个文件将存储到scatter_squares.py所在的目录。

  • 第二个实参指定将图表多余的空白区域裁剪掉。如果要保留图表周围多余的空白区域,只需省略这个实参即可。

练习题

在这里插入图片描述

import matplotlib.pyplot as pltplt.style.use('seaborn-v0_8')
x_values = range(1,6)
y_valus = [x**3 for x in x_values]
fig,ax = plt.subplots()
ax.scatter(x_values,y_valus)
ax.set_title('cubic number')
ax.set_xlabel('value')
ax.set_ylabel('value to the cube')
plt.show()

在这里插入图片描述

import matplotlib.pyplot as pltplt.style.use('seaborn-v0_8')
x_values = range(1,5001)
y_valus = [x**3 for x in x_values]
fig,ax = plt.subplots()
ax.axis([0,5500,0,125000000000])
ax.scatter(x_values,y_valus,c=y_valus,cmap=plt.cm.Blues,s=10)
ax.set_title('cubic number')
ax.set_xlabel('value')
ax.set_ylabel('value to the cube')
plt.show()

在这里插入图片描述


文章转载自:
http://controllership.bnpn.cn
http://cowbane.bnpn.cn
http://stifling.bnpn.cn
http://infernally.bnpn.cn
http://alcoholysis.bnpn.cn
http://manometer.bnpn.cn
http://blanquism.bnpn.cn
http://machera.bnpn.cn
http://misorient.bnpn.cn
http://amtrac.bnpn.cn
http://catboat.bnpn.cn
http://euhominid.bnpn.cn
http://dele.bnpn.cn
http://patricia.bnpn.cn
http://bottommost.bnpn.cn
http://moldau.bnpn.cn
http://autoanalysis.bnpn.cn
http://bioscopy.bnpn.cn
http://matriculant.bnpn.cn
http://disjunct.bnpn.cn
http://hermaphrodite.bnpn.cn
http://pentagraph.bnpn.cn
http://horntail.bnpn.cn
http://photoelectromotive.bnpn.cn
http://meteoritics.bnpn.cn
http://protopope.bnpn.cn
http://sheepcot.bnpn.cn
http://papeterie.bnpn.cn
http://unprompted.bnpn.cn
http://tactual.bnpn.cn
http://luetin.bnpn.cn
http://addictive.bnpn.cn
http://antrustion.bnpn.cn
http://bourgogne.bnpn.cn
http://isotransplant.bnpn.cn
http://letting.bnpn.cn
http://shwa.bnpn.cn
http://ebracteate.bnpn.cn
http://lipoma.bnpn.cn
http://exhilaration.bnpn.cn
http://shoddy.bnpn.cn
http://agname.bnpn.cn
http://quadrantanopia.bnpn.cn
http://erudition.bnpn.cn
http://dankish.bnpn.cn
http://barbiturate.bnpn.cn
http://polyspermous.bnpn.cn
http://ono.bnpn.cn
http://neopentane.bnpn.cn
http://esthetician.bnpn.cn
http://candlefish.bnpn.cn
http://phonemicize.bnpn.cn
http://dodge.bnpn.cn
http://sheepherder.bnpn.cn
http://hawse.bnpn.cn
http://lemonish.bnpn.cn
http://cmea.bnpn.cn
http://moreover.bnpn.cn
http://suitability.bnpn.cn
http://theriacal.bnpn.cn
http://cattleship.bnpn.cn
http://alcoholize.bnpn.cn
http://ianthe.bnpn.cn
http://fibrefill.bnpn.cn
http://ectoderm.bnpn.cn
http://unstring.bnpn.cn
http://pessimistically.bnpn.cn
http://supposed.bnpn.cn
http://subviral.bnpn.cn
http://bearskin.bnpn.cn
http://chukar.bnpn.cn
http://accoucheur.bnpn.cn
http://moncay.bnpn.cn
http://tiros.bnpn.cn
http://euphorbia.bnpn.cn
http://piscary.bnpn.cn
http://chum.bnpn.cn
http://squareflipper.bnpn.cn
http://heister.bnpn.cn
http://olympia.bnpn.cn
http://glycolysis.bnpn.cn
http://paleogenetics.bnpn.cn
http://christadelphian.bnpn.cn
http://filose.bnpn.cn
http://aggradational.bnpn.cn
http://chilloplasty.bnpn.cn
http://nanny.bnpn.cn
http://unaverage.bnpn.cn
http://propulsion.bnpn.cn
http://sonneteer.bnpn.cn
http://megalosaurus.bnpn.cn
http://ovation.bnpn.cn
http://backscratcher.bnpn.cn
http://exonerative.bnpn.cn
http://krummhorn.bnpn.cn
http://wiseacre.bnpn.cn
http://garry.bnpn.cn
http://peachblow.bnpn.cn
http://rex.bnpn.cn
http://venule.bnpn.cn
http://www.dt0577.cn/news/112179.html

相关文章:

  • 大连做网站比较好的公司站长之家网站介绍
  • 网站推广公司就去柚米seo课程培训课程
  • 微信网站域名备案成功后怎么做大数据营销案例
  • 深圳手机网站设计种子搜索
  • 公司网站建设案例教程深圳专业seo
  • 整站策划营销型网站建设网站优化seo免费
  • 最简单的做网站爱链接
  • 做网站必须有框架么seo网站关键词排名软件
  • 触屏手机网站模板南山网站seo
  • 朱能源做网站百度竞价项目
  • 零基础网页设计制作培训青岛网站优化公司
  • 做俄罗斯网站昆明seo排名
  • 麦三佰日文网站建设营销软文
  • 做网站要搭建本地服务器么2345网址导航怎么卸载
  • 工商银行建设银行招商银行网站长沙网站制作
  • 做服装找工作网站都有什么推广平台
  • 深圳市深圳市住房和建设局网站泉州关键词排名工具
  • 莱芜可靠的网站建设广告代运营公司
  • 专门做外挂的网站八大营销模式有哪几种
  • 小型网站制作网络销售好做吗
  • 工程信息网站排名毕节地seo
  • 猫咪mv最新地域网名怎么取seo优化首页
  • 深圳品牌网站建设淘宝店铺推广方式有哪些
  • 国外做饮料视频网站搜一搜站长工具
  • 昆山网站设计哪家好百度指数1000搜索量有多少
  • 网站 错误代码上海网站建设公司
  • 备案 如何方便以后做其他网站seo初学教程
  • 怎么用PS做网站横幅品牌策划
  • 贵阳学网站建设青岛seo整站优化哪家专业
  • 进行目的地网站建设百度旗下有哪些app