y=2x+3

import matplotlib.pyplot as plt#约定俗成的写法plt
#首先定义两个函数(正弦&余弦)
import numpy as np
#plt.figure(num='正余弦函数图', figsize=(10, 6), dpi=120, facecolor='y', edgecolor='g')
X=np.linspace(-np.pi,np.pi,256,endpoint=True)#-π to+π的256个值
#C,S=np.cos(X),np.sin(X)
S=2*X+3
#S=(X*X)/(1-X)
#S=X*X+2*X
#plt.plot(X,C,color='red', linestyle='-', linewidth=2, label='$sin(x)$')
plt.plot(X,S,color='red', linestyle='-', linewidth=2)
#plt.axis((-6.5, 6.5, -2.1, 2.1)) #轴的取值范围
#在ipython的交互环境中需要这句话才能显示出来
plt.xlabel('X axis')
plt.ylabel('Y axis')
#plt.yticks((-1, 0, 1))
# 设置、显示legend
plt.legend(loc='best') # loc参数设置图例显示的位置
plt.legend(loc='best') # loc参数设置图例显示的位置
plt.title('cos&sin')
plt.text(-np.pi, 1, 'cos',fontdict={'size': 10, 'color': 'y'}) # text在图中任意位置添加文字,前两个参数是左下角的位置坐标
plt.annotate('max', xy=(0, 1), xytext=(1, 1.05), arrowprops=dict(facecolor='k', shrink=1)) # 注释的地方xy(x,y)和插入文本的地方
# 移动坐标轴,spines为脊梁,即4个边框
ax = plt.gca() # gca stands for 'get current axis'
ax.spines['right'].set_color('none') # 设置右‘脊梁’为无色
ax.spines['top'].set_color('none') # 设置上‘脊梁’为无色
ax.xaxis.set_ticks_position('bottom') # 底部‘脊梁’设置为X轴
ax.spines['bottom'].set_position(('data', 0)) # 底部‘脊梁’移动位置,y的data
ax.yaxis.set_ticks_position('left') # 左部‘脊梁’设置为Y轴
ax.spines['left'].set_position(('data', 0)) # 左部‘脊梁’移动位置,x的data
plt.savefig('d:/test2.png')
plt.show()

y=1/2*X*X

修改;

S=1/2*X*X
y=1/3*x*x*3
S=1/3*X*X*X



S=X*X*X/(X-1)

余玄函数
S=np.cos(X)


正玄函数
S=np.sin(X)

S=np.tan(X)
双曲正切
S=np.tanH(X)

对数函数
S=np.log2(X)
S=pow(np.e,X)
 

python matplotlib生成图形的更多相关文章

  1. python matplotlib画图产生的Type 3 fonts字体没有嵌入问题

    ScholarOne's 对python matplotlib画图产生的Type 3 fonts字体不兼容,更改措施: 在程序中添加如下语句 import matplotlib matplotlib. ...

  2. matplotlib 生成 eps 插入到 tex

    matplotlib 生成 eps 插入到 tex matplotlib 生成 eps,就可以插入到 tex 中,而且是矢量图,放大不失真. 而且因为图中的元素都是嵌入到 pdf 中,所以图中的文字也 ...

  3. python matplotlib plot 数据中的中文无法正常显示的解决办法

    转发自:http://blog.csdn.net/laoyaotask/article/details/22117745?utm_source=tuicool python matplotlib pl ...

  4. Python - matplotlib 数据可视化

    在许多实际问题中,经常要对给出的数据进行可视化,便于观察. 今天专门针对Python中的数据可视化模块--matplotlib这块内容系统的整理,方便查找使用. 本文来自于对<利用python进 ...

  5. 转:使用 python Matplotlib 库 绘图 及 相关问题

     使用 python Matplotlib 库绘图      转:http://blog.csdn.net/daniel_ustc/article/details/9714163 Matplotlib ...

  6. 安装python Matplotlib 库

    转:使用 python Matplotlib 库 绘图 及 相关问题  使用 python Matplotlib 库绘图      转:http://blog.csdn.net/daniel_ustc ...

  7. 十分钟快速学会Matplotlib基本图形操作

    在学习Python的各种工具包的时候,看网上的各种教程总是感觉各种方法很多很杂,参数的种类和个数也十分的多,理解起来需要花费不少的时间. 所以我在这里通过几个例子,对方法和每个参数都进行详细的解释,这 ...

  8. Python绘制3D图形

    来自:https://www.jb51.net/article/139349.htm 3D图形在数据分析.数据建模.图形和图像处理等领域中都有着广泛的应用,下面将给大家介绍一下如何使用python进行 ...

  9. python matplotlib.pyplot 散点图详解(1)

    python matplotlib.pyplot散点图详解(1) 一.创建散点图 可以用scatter函数创建散点图 并使用show函数显示散点图 代码如下: import matplotlib.py ...

随机推荐

  1. (比赛)C - 小Q系列故事——最佳裁判(水题)

    C - 小Q系列故事——最佳裁判 Time Limit:200MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Des ...

  2. python之while循环用法举例,break与continue的区别,格式化输出及运算符

    一.while循环的基本结构 while 条件: 代码块(循环体) else: 当上面的条件为假. 才会执行 执行顺序:判断条件是否为真. 如果真. 执行循环体. 然后再次判断条件....直到循环条件 ...

  3. OSI标准协议分析

    1.各个层的作用 物理层:(physical Layer):物理层负责传送比特(Bit),涉及到接口和传输媒体的机械 电气特性 数据链路层:(data link layer):数据链路层负责传送的帧( ...

  4. Multiple network matches found for name 'selfservice', use an ID to be more specific.报错

    今天正在做openstack实例时输入neutron subnet-create --name selfservice   --dns-nameserver 114.114.114.114 --gat ...

  5. Alluxio : 开源分布式内存文件系统

    Alluxio : 开源分布式内存文件系统 Alluxio is a memory speed virtual distributed storage system.Alluxio是一个开源的基于内存 ...

  6. HDU2870 Largest Submatrix

    Largest Submatrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. sublime test 3 配置安装fortran开发环境

    1.ST3下安装包管理工具Package Control https://jingyan.baidu.com/article/3c343ff7dca2b10d3779633b.html ST主界面下c ...

  8. idea-git同步服务器代码后撤销操作

    工具:IntelliJ IDEA 2019.2.1 x64 记录一次不小心同步代码后,如何撤销操作. 1.同步服务器代码,右击项目,点击Synchronize 'xxx',如下: 2.打开Versio ...

  9. learning java AWT 布局管理器FlowLayout

    AWT提供了FlowLayout   从左到右排列所有组件,遇到边界就会折回下一行重新开始. import java.awt.*; public class FlowLayoutTest { publ ...

  10. __try __except与__try __finally的嵌套使用以及__finally的调用时机

    原文:https://blog.csdn.net/SwordArcher/article/details/82465522 try-finally语句的语法与try-except很类似,稍有不同的是, ...