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

网站功能是什么公司网站建设价格标准

网站功能是什么,公司网站建设价格标准,音视频娱乐网站开发商,昆明做网站开发维护的公司本文只介绍最简单基本的画图方法 预设 要想画出来的图有些逼格,首先应该进行如下设置 plt.rcParams[font.sans-serif][SimHei] #画图时显示中文字体 plt.rcParams[axes.unicode_minus] False #防止因修改成中文字符,导致某些 unicode 字符不能…

本文只介绍最简单基本的画图方法

预设

要想画出来的图有些逼格,首先应该进行如下设置

plt.rcParams['font.sans-serif']=['SimHei']    #画图时显示中文字体
plt.rcParams['axes.unicode_minus'] = False     #防止因修改成中文字符,导致某些 unicode 字符不能显示
plt.subplots_adjust(left=None, bottom=None, right=None, top=None,wspace=0.3)    #设置制子图之间的左右间距,left 等是设置画图区域与画布之间的间font1 = {'family' : 'SimHei',
'weight' : 'normal',
'size'   : 15,
}   #设置图例(legend)文字的格式的

绘制多幅图

基本格式:

fig = plt.figure(figsize=())
ax1 = plt.subplot(m,n,1)  #m 为行、n为列、1 为图序
plt.plot(xxxxx)ax2 = plt.subplot(m,n,2)
plt.plot(xxxx)......
示例如下:
```python
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,2*np.pi,100)
y1 = np.sin(x)
y2 = np.cos(x)
y3 = x+1fig = plt.figure(figsize=(12,4))  #宽度、高度
ax1 = plt.subplot(1,3,1)
plt.plot(x,y1,linewidth=1.5,color='c',label=r'$y_1$',marker='o',markersize=4)
plt.xlabel('x',fontsize=24)
plt.ylabel(r'$y_1$',fontsize=24)
plt.ylim([-1,1])
plt.xlim([0,2*np.pi])
plt.legend(prop=font1,loc='best')
plt.grid()ax2 = plt.subplot(1,3,2)
plt.plot(x,y2,linewidth=3,color='r',label=r'$y_2$',linestyle='-.')
plt.xlabel('x',fontsize=24)
plt.ylabel(r'$y_2$',fontsize=24)
plt.ylim([-1,1])
plt.xlim([0,2*np.pi])
plt.legend(prop=font1,loc='best')
plt.grid()ax3 = plt.subplot(1,3,3)
plt.plot(x,y3,linewidth=1.5,color='b',label=r'$y_3$',linestyle='--')
plt.xlabel('x',fontsize=24)
plt.ylabel(r'$y_3$',fontsize=24)
plt.legend(prop=font1,loc='best')
plt.grid()

在这里插入图片描述
另外。plt.title 也可以设图片的标题,子图的标题也行

画骨骼图

先看效果:
在这里插入图片描述
这里要用 axe 来画图,而不能直接用 plt,代码如下:

def sigmoid(x):return 1./(1.+np.exp(-x))def relu(x):return np.where(x<0,0,x)def tanh(x):return 2*sigmoid(2*x)-1font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 14,
}def plot_tran_fun():   plt.rcParams['font.sans-serif']=['SimHei']plt.rcParams['axes.unicode_minus'] = Falsefig = plt.figure(figsize=(8,6))ax1 = plt.subplot(2,2,1)x = np.arange(-10, 10)y = sigmoid(x)ax.spines['top'].set_color('none')ax.spines['right'].set_color('none')ax.xaxis.set_ticks_position('bottom')ax.spines['bottom'].set_position(('data',0))ax.set_xticks([-10,-5,0,5,10])ax.yaxis.set_ticks_position('left')ax.spines['left'].set_position(('data',0))ax.plot(x,y,label="Sigmoid",color = "blue")plt.legend(prop=font1,loc='lower right')
#    plt.show()
#
#    ax2 = plt.subplot(2,2,2)x = np.arange(-10, 10)y = tanh(x)ax.spines['top'].set_color('none')ax.spines['right'].set_color('none')ax.xaxis.set_ticks_position('bottom')ax.spines['bottom'].set_position(('data',0))ax.set_xticks([-10,-5,0,5,10])ax.yaxis.set_ticks_position('left')ax.spines['left'].set_position(('data',0))ax.plot(x,y,label="Tanh",color = "blue")plt.legend(prop=font1)
#    ax.show()   
#    ax = fig.add_subplot(223)
#     x = np.arange(-10, 10)y = relu(x)ax.spines['top'].set_color('none')ax.spines['right'].set_color('none')ax.xaxis.set_ticks_position('bottom')ax.spines['bottom'].set_position(('data',0))ax.set_xticks([-10,-5,0,5,10])ax.yaxis.set_ticks_position('left')ax.spines['left'].set_position(('data',0))ax.plot(x,y,label="ReLU",color = "blue")plt.legend(prop=font1)     
#    ax = fig.add_subplot(224)
#     x = np.arange(-10, 10)y = xax.spines['top'].set_color('none')ax.spines['right'].set_color('none')ax.xaxis.set_ticks_position('bottom')ax.spines['bottom'].set_position(('data',0))ax.set_xticks([-10,-5,0,5,10])ax.yaxis.set_ticks_position('left')ax.spines['left'].set_position(('data',0))ax.plot(x,y,label="Linear",color = "blue")plt.legend(prop=font1)plot_tran_fun()

其他画图

画出包围部分

一般用在画积分面积的时候,代码如下:

fig = plt.figure(figsize=(6,4))
plt.plot(x,y1,x,y2)
plt.fill_between(x,y1,y2,facecolor='k',alpha=0.2)
plt.text(1.5,0,'包围部分',fontsize=20)
plt.title('画出包围部分',fontsize=16)

在这里插入图片描述

散点图

plt.scatter(x,y,s=None,c=None,marker=None,alpha=None)

其中 s 为每一个点的大小,若传入的是一个列表或者 array,则array匹配每一个点的大小; c 表示点的颜色,若传入的是列表或者 array,则匹配每一个点的颜色

from sklearn.datasets import make_gaussian_quantiles  
X, y = make_gaussian_quantiles(n_samples=300,n_features=2, n_classes=2)  #产生数据集
X0 = X[y.ravel()==0]
plt.scatter(X0[:, 0], X0[:, 1], marker='o')  
X1 = X[y.ravel()==1]
plt.scatter(X1[:, 0], X1[:, 1], marker='x') 

散点图结果

柱状图

plt.bar(x,height,width,color)
其中 height 是柱状图的高度,即 y;

x = np.arange(10)
y1 = np.random.randn(10)
y2 = np.random.randn(10)
fig = plt.figure(figsize=(6,4))
plt.bar(x,y1,width=0.35,color='g')
plt.bar(x+0.35,y2,width=0.35,color='b')
plt.xlabel('x',fontsize=16)
plt.ylabel('y',fontsize=16)

在这里插入图片描述

饼状图

plt.pie(x,labels=None,explode=None,colors=None,autopct=None)
其中:x 为待表示数据;label 接受一个 array,分别对应 x 的标签,explode 接受 array,表示饼状图离圆心的距离(用半径的百分比表示);colors 可以接受 array,表示每一个饼的颜色,autopct 是设置比例的表示方法,如 %1.1f %%(第二个 % 是为了转意)

x = [15,20,30,40]
explode = [0.05]*len(x)
autopct = '%1.1f %%'
labels = ['one','two','three','four']
fig = plt.figure(figsize=(6,4))
patches,l_text,p_text = plt.pie(x,labels=labels,explode=explode,autopct=autopct)
#l_text,p_text 是为了设置饼状图的文本。l_text 是labels的文本,p_text 是图内部的文本(比例)
for t in l_text:t.set_size(30)
for t in p_text:t.set_size(20)

在这里插入图片描述

箱型图

plt.boxplot(df,sym,meanline)
df:为箱型图绘制的数据,以列为单位进行绘制
sym:为异常点的形状
meanline:是否展示平均线

import pandas as pd
df = pd.DataFrame(np.random.randn(5,4),columns=['A','B','C','D'])
fig = plt.figure(figsize=(6,4))
plt.boxplot(df,sym='o',meanline=True)

在这里插入图片描述
若要设置 xticks,则需要用到 ax,如下:

df = pd.DataFrame(np.random.randn(5,4),columns=['A','B','C','D'])
fig = plt.figure(figsize=(6,4))
ax = plt.subplot()ax.boxplot(df,sym='o')
ax.set_xticklabels(['A','B','C','D'])

频率直方图

import pandas as pd
x = np.random.normal(0,1,size=(100))
fig = plt.figure(figsize=(6,4))
bin_num = 10
plt.hist(x,bin_num)

在这里插入图片描述

http://www.yayakq.cn/news/691411/

相关文章:

  • 方正园林建设监理中心网站网站企业业务员怎么做
  • 宁波网站制作出售英文网站开发公司哪家好
  • 旅游网站建设的目的及功能定位湖南省建设厅证件查询
  • 天津网站搜索排名优化定制旅游哪个网站好用
  • 网站如何运营wordpress中文用户名注册
  • 网站管理助手数据库godaddy上传网站
  • 苏州网站优化公司WordPress添加有趣的
  • 自己做网站销售网络营销的流程和方法
  • 做民宿最大的网站有谁做分销网站
  • asp个人网站论文苏州建站推广定制
  • 饭店网站模板企业公示信息查询系统湖北
  • 品牌网站建设怎么收费襄樊北京网站建设
  • 网站模板 登陆手机app用什么工具开发
  • 有哪些可以做图的网站啊企业邮箱是多少怎么查
  • 百度网站建设开场话术iis本地网站
  • 门户类网站开发多少钱贵阳网站备案核验点照相
  • 嘉兴品牌网站建设dede网站地图栏目如何上传文件
  • 杯子网站开发方案风铃做的网站能否推广
  • 网站建设公司市场策划方案梵克雅宝官网手链报价
  • 网站关键词优化怎么做的网站做跳转影响排名吗
  • 在网站做的pdf有水印如何删除办公网站模板
  • 内江做网站的公司wordpress 导航登录
  • 网站开发安装win10家庭版摄影标志logo设计欣赏
  • 网页建站工具如何在手机上学编程
  • 企业网站管理系统cms网店美工考试
  • wordpress降低使用内存seo入门基础教程
  • 企业网站邮箱建设三个关键词介绍自己
  • 阿里云 外贸网站wordpress 很卡
  • 网站后台开发教程一个软件app
  • 外贸饰品网站关键词搜索引擎网站