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

中山网站建设公司哪家好蜜雪冰城网络营销案例分析

中山网站建设公司哪家好,蜜雪冰城网络营销案例分析,卖域名出去客户犯法怎么办,做app还是做微网站好介绍 在官网上有更多种类的图型的绘制方法 matpoltlib中文官方文档:例子_Matplotlib 中文网 matpoltlib英文官方文档:Examples — Matplotlib 3.8.1 documentation 分类 一、折线图 1、要实现的功能: 2、实例: # 导入包 from…

介绍

在官网上有更多种类的图型的绘制方法

matpoltlib中文官方文档:例子_Matplotlib 中文网

matpoltlib英文官方文档:Examples — Matplotlib 3.8.1 documentation

分类

一、折线图

1、要实现的功能:

2、实例:

# 导入包
from matplotlib import pyplot as plt
#这句话还可以用:from matplotlib import pyplot as plt# 创建数据
x = range(2, 26, 2)
y = [15, 13, 14.5, 17, 20, 25, 26, 26, 27, 22, 18, 15]
y2 = [1, 0, 11, 12, 13, 14, 3, 10, 1, 1, 1, 2]# 设置图片尺寸和清晰度,dpi表示分辨率,即每英寸的点数,默认80
plt.figure(figsize=(20, 8), dpi=200)# 绘制折线图
plt.plot(x, y, label='line_1')
plt.plot(x, y2, label='line_2', color='r', linestyle="--", linewidth=5, alpha=0.5)#设置线颜色、线条样式、线条宽度、线条透明度# 设置曲线标签;需要先在plot函数中设置label参数,
plt.legend()  # 默认标签显示在右上角;对参数loc赋值可使label显示在不同位置# 设置x、y轴刻度(数字的情况下)
xticks_labels = [i/2 for i in range(2, 50)]
plt.xticks(xticks_labels)
plt.yticks(range(0, max(y)+1))
# 设置x、y刻度(字符串情况下);传入两个参数,都为列表形式,两个列表对应;rotation代表旋转角度
plt.xticks(xticks_labels, [f"No.{i}" for i in xticks_labels], rotation = 45)# 添加标题和标签
plt.title('Simple Line Plot')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')# 设置网格
plt.grid()
#  plt.grid(alpha = 0.2)  #参数alpha表示网格透明度# 保存图片
plt.savefig("./t1.png")
plt.savefig("./t2.svg")   # .svg矢量图格式,放大不会有锯齿# 显示图形
plt.show()

3、逐句解释:

(1)导入包

# 导入包
from matplotlib import pyplot as plt
#这句话还可以用:from matplotlib import pyplot as plt

(2)创建数据

# 创建数据
x = range(2, 26, 2)
y = [15, 13, 14.5, 17, 20, 25, 26, 26, 27, 22, 18, 15]
y2 = [1, 0, 11, 12, 13, 14, 3, 10, 1, 1, 1, 2]

(3)设置图片尺寸和清晰度,dpi表示分辨率,即每英寸的点数,默认80

# 设置图片尺寸和清晰度,dpi表示分辨率,即每英寸的点数,默认80
plt.figure(figsize=(20, 8), dpi=200)

(4)绘制折线图,plot中,参数可以设置:“ 线条颜色、线条样式、线条宽度、线条透明度 ”

# 绘制折线图
plt.plot(x, y, label='line_1')
plt.plot(x, y2, label='line_2', color='r', linestyle="--", linewidth=5, alpha=0.5)#设置线颜色、线条样式、线条宽度、线条透明度

(5)在一个表中显示多个折线图,多次调用plot函数绘图即可,可用 legend 生成图例,不同折线标签是由 plot 中的 label 参数设置,legend 中参数可设置标签的各项特点。

# 设置曲线标签;需要先在plot函数中设置label参数,
plt.legend()  # 默认标签显示在右上角;对参数loc赋值可使label显示在不同位置

(6)设置x、y轴的刻度,数字情况是传入一个列表参数,字符串情况是传入两个相互对应的列表参数

# 设置x、y轴刻度(数字的情况下)
xticks_labels = [i/2 for i in range(2, 50)]
plt.xticks(xticks_labels)
plt.yticks(range(0, max(y)+1))
# 设置x、y刻度(字符串情况下);传入两个参数,都为列表形式,两个列表对应;rotation代表旋转角度
plt.xticks(xticks_labels, [f"No.{i}" for i in xticks_labels], rotation = 45)

(7)设置标题和x、y轴标签

# 添加标题和标签
plt.title('Simple Line Plot')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')

(8)设置网格,alpha参数代表网格透明度,范围0-1

# 设置网格
plt.grid()
#  plt.grid(alpha = 0.2)  #参数alpha表示网格透明度

(9)保存图片,svg矢量图格式可以防止放大图线后出现模糊

# 保存图片
plt.savefig("./t1.png")
plt.savefig("./t2.svg")   # .svg矢量图格式,放大不会有锯齿

(10)显示图线

# 显示图形
plt.show()

二、散点图

将  plot()  换成  scatter()  即可。其余与折线图完全一样。

三、条形图

1、竖着的条形图

from matplotlib import pyplot as plta = ["no1", "no2", "no3", "no4", "no5", "no6", "no7", "no8", "no9"]
b = [56.1, 26.94, 17.53, 16.49, 15.45, 12.96, 11.8, 11.61, 11]# 设置图形大小
plt.figure(figsize=(20, 8), dpi=80)# 绘制条形图
plt.bar(range(len(a)), b, width=0.3)# 设置字符串到x轴
plt.xticks(range(len(a)), a, rotation=90)plt.show()

2、横着的条形图

from matplotlib import pyplot as plta = ["no1", "no2", "no3", "no4", "no5", "no6", "no7", "no8", "no9"]
b = [56.1, 26.94, 17.53, 16.49, 15.45, 12.96, 11.8, 11.61, 11]# 设置图形大小
plt.figure(figsize=(20, 8), dpi=80)# 绘制条形图
plt.barh(range(len(a)), b, height=0.3)# 设置字符串到x轴
plt.yticks(range(len(a)), a)plt.show()

3,区别

(1)竖图和横图用的绘图函数分别为 bar() 和 barh() ,

(2)若竖图设置的是x轴,其对应的横图就应该设置y轴。

(3)竖图设置条的宽度用width参数,横图用height参数

四、直方图

用 hist() 绘制直方图,参数density默认为False,表示绘制频率分布直方图,设置为True 表示绘制概率分布直方图(面积归一化)

from matplotlib import pyplot as plta = [112,134,173,156,88,93,140,150,130,133,122,123,132,145,154,154,154,123,165,147,99,95,149,120,123,93,92,154,123,134,135,154,153,133,122,123,154,145,134,145,164,163,162,166,126,134,143,155,156,167,133,134,155,159,158,138,139,134,137,147,148,149,133,134,144,134,143,133,170,167,145,123,134,165,122,102,101,100,102,103,103,104,105,106,107,148,109,112,113,114,115,112,111,111,110,114,113,123,133,116]d = 5    # 组距
num_bins = (max(a)-min(a))//d
print(len(a), max(a), min(a), max(a)-min(a))
print(num_bins)# 设置图形大小
plt.figure(figsize=(20, 8), dpi=80)
plt.hist(a, num_bins, density=True) # density设置为True表示概率分布直方图(面积归一化),默认density为False,为频率分别直方图# 设置x轴刻度
plt.xticks(range(min(a), max(a)+d, d))plt.grid()plt.show()

hist() 中第二个参数若为一个数字num,则代表平均分为num组,若为一个列表,则可以按照列表分组,这个列表中的数代表的并不是比例,而是横坐标的数字,如将上代码中的 hist() 的第二个参数改为 [60,70,80,90,100,125,155,160,170,180],可得到:

此时应更改横坐标也为[60,70,80,90,100,125,155,160,170,180]


文章转载自:
http://necrologist.qrqg.cn
http://declivous.qrqg.cn
http://assessment.qrqg.cn
http://platinoid.qrqg.cn
http://hued.qrqg.cn
http://indiana.qrqg.cn
http://consequent.qrqg.cn
http://diminuendo.qrqg.cn
http://skillion.qrqg.cn
http://refrangibility.qrqg.cn
http://detumescent.qrqg.cn
http://danite.qrqg.cn
http://demerit.qrqg.cn
http://dance.qrqg.cn
http://diarist.qrqg.cn
http://fagoting.qrqg.cn
http://phonochemistry.qrqg.cn
http://magdalenian.qrqg.cn
http://briar.qrqg.cn
http://malines.qrqg.cn
http://gasometrical.qrqg.cn
http://isogonal.qrqg.cn
http://placentiform.qrqg.cn
http://nightfall.qrqg.cn
http://entomophagous.qrqg.cn
http://aneuria.qrqg.cn
http://mirthful.qrqg.cn
http://fujian.qrqg.cn
http://gonogenesis.qrqg.cn
http://veterinarian.qrqg.cn
http://razzia.qrqg.cn
http://inviolacy.qrqg.cn
http://reproachingly.qrqg.cn
http://ceratodus.qrqg.cn
http://basse.qrqg.cn
http://metafiction.qrqg.cn
http://trevet.qrqg.cn
http://tuberculin.qrqg.cn
http://blair.qrqg.cn
http://teutonism.qrqg.cn
http://alarum.qrqg.cn
http://astrogation.qrqg.cn
http://capernaism.qrqg.cn
http://eagerly.qrqg.cn
http://syntone.qrqg.cn
http://poltava.qrqg.cn
http://jaspagate.qrqg.cn
http://interstrain.qrqg.cn
http://picky.qrqg.cn
http://madam.qrqg.cn
http://nibmar.qrqg.cn
http://macroprocessor.qrqg.cn
http://undauntable.qrqg.cn
http://ratbag.qrqg.cn
http://ethnocracy.qrqg.cn
http://ugric.qrqg.cn
http://scan.qrqg.cn
http://housetop.qrqg.cn
http://doting.qrqg.cn
http://bushwhack.qrqg.cn
http://forgiveness.qrqg.cn
http://biosphere.qrqg.cn
http://levelpeg.qrqg.cn
http://tricarpellary.qrqg.cn
http://bernardine.qrqg.cn
http://incase.qrqg.cn
http://hornful.qrqg.cn
http://thyroglobulin.qrqg.cn
http://barbital.qrqg.cn
http://spanish.qrqg.cn
http://valiancy.qrqg.cn
http://center.qrqg.cn
http://mythologise.qrqg.cn
http://pikake.qrqg.cn
http://playgoing.qrqg.cn
http://sapporo.qrqg.cn
http://biographee.qrqg.cn
http://quezon.qrqg.cn
http://malwa.qrqg.cn
http://neoplasm.qrqg.cn
http://reservedly.qrqg.cn
http://tympanum.qrqg.cn
http://sheraton.qrqg.cn
http://adroitly.qrqg.cn
http://mucrones.qrqg.cn
http://anthropomorphic.qrqg.cn
http://tankage.qrqg.cn
http://bravo.qrqg.cn
http://midiron.qrqg.cn
http://xylotile.qrqg.cn
http://impar.qrqg.cn
http://cecile.qrqg.cn
http://borrower.qrqg.cn
http://seceder.qrqg.cn
http://bourgeon.qrqg.cn
http://sunwards.qrqg.cn
http://glooming.qrqg.cn
http://rebuttal.qrqg.cn
http://fluoridationist.qrqg.cn
http://sonless.qrqg.cn
http://www.dt0577.cn/news/59350.html

相关文章:

  • 做知识产权相关的网站短视频搜索seo
  • 集团网站建设公司站长工具关键词挖掘
  • 济南网站网站建设重庆seo优化推广
  • 旅行做攻略的网站好湖南网站建设平台
  • 做设计必须知道的几个网站推广app最快的方法
  • 做360网站快速排名软件预防电信网络诈骗
  • c 手机网站开发工具seo网络推广公司
  • 做网站初中新网
  • 莞城网站制作谷歌浏览器网页版入口
  • 新网主机不能指向其他网站免费制作网站平台
  • 过年做哪些网站能致富十大看免费行情的软件下载
  • 湖南网站建设有限公司免费网站制作平台
  • 最新聊天记录做图网站cnn头条新闻
  • 军民融合网站建设长沙官网优化公司
  • 网站单页模板杭州seo服务公司
  • 道路运输电子证照上海关键词排名优化怎样
  • 网站评论怎么做的凡科建站代理
  • 如何做自己的网站链接有人百度看片吗
  • 优质的聊城做网站新手怎么开始做电商
  • 网站的联网信息怎么填seo整站优化方案案例
  • 用自己网站域名这么做邮箱网络推广的主要工作内容
  • 企业网站建设重要性如何快速搭建一个网站
  • 东莞营销网站开发网页设计案例
  • wordpress 500 阿里云北京seo代理计费
  • wordpress title description排名优化网站
  • 网站备案名字填写seo高效优化
  • 电子商务网站建设与维护考试题网络营销代运营外包公司
  • 哪个网站找到做箱包厂外发的南京网页搜索排名提升
  • 制作百度移动网站app开发公司排名
  • 云服务器建站微信营销平台