-
大小: 43KB文件类型: .zip金币: 2下载: 0 次发布日期: 2021-06-14
- 语言: Python
- 标签: Python matplotlib 绘图
资源简介
实现了一个基于Python matplotlib的函数绘图计算器,可实现二维三维绘图和解线性方程组,全部图形界面显示,界面友好,易操作,有详细的readMe指导和注释。

代码片段和文件信息
import numpy as np
from numpy import inf nan e abs
# 在eval函数中使用到math所以勿删math
# from sympy import exp symbols integrate oo sin cos log tan pi factorial E erfi
# from sympy import asin acos atan sinh cosh tanh summation diff limit Integral Abs AccumBounds
import sympy
from sympy import *
# 对话框所需的库
# 创建画布需要的库
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
# 创建工具栏需要的库
from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk
# 快捷键需要的库
from matplotlib.backend_bases import key_press_handler
# 导入画图常用的库
from matplotlib.pyplot import figure
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
class ZoomPan:
“““
放大或缩小函数图像
移动函数图像
“““
def __init__(self):
self.press = None
self.cur_xlim = None
self.cur_ylim = None
self.x0 = None
self.y0 = None
self.x1 = None
self.y1 = None
self.xpress = None
self.ypress = None
def zoom_factory(self string1 x y string ax base_scale=2.):
def zoom(event):
nonlocal x y string string1
cur_xlim = ax.get_xlim()
cur_ylim = ax.get_ylim()
xdata = event.xdata # get event x location
ydata = event.ydata # get event y location
if event.button == ‘up‘:
# deal with zoom in
scale_factor = 1 / base_scale
elif event.button == ‘down‘:
# deal with zoom out
scale_factor = base_scale
else:
# deal with something that should never happen
scale_factor = 1
new_width = (cur_xlim[1] - cur_xlim[0]) * scale_factor
new_height = (cur_ylim[1] - cur_ylim[0]) * scale_factor
relx = (cur_xlim[1] - xdata) / (cur_xlim[1] - cur_xlim[0])
rely = (cur_ylim[1] - ydata) / (cur_ylim[1] - cur_ylim[0])
ax.set_xlim([xdata - new_width * (1 - relx)
xdata + new_width * relx])
ax.set_ylim([ydata - new_height * (1 - rely)
ydata + new_height * rely])
if string != ““:
if string.find(‘log‘) != -1 or string.find(‘sqrt‘) != - \
1 or string.find(‘!‘) != -1:
x = np.linspace(0.0001 ax.get_xlim()[1] 100)
elif string.find(‘asin‘) != -1 or string.find(‘acos‘) != -1 or string.find(‘atan‘) != -1:
x = np.linspace(-1 1 100)
else:
x = np.linspace(ax.get_xlim()[0] ax.get_xlim()[1] 100)
y = [eval(string) for i in x]
else:
x = []
y = []
# while len(ax.lines) != 0:
# ax.lines.pop(0)
ax.lines = []
handle = ax.plot(x y)
ax.grid(True)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-01-09 17:26 基于matplotlib的函数计算器\
文件 361 2020-01-09 17:27 基于matplotlib的函数计算器\ReadMe.md
目录 0 2020-01-09 17:26 基于matplotlib的函数计算器\calculator\
目录 0 2020-01-09 17:26 基于matplotlib的函数计算器\calculator\.idea\
文件 408 2019-06-20 14:17 基于matplotlib的函数计算器\calculator\.idea\calculator.iml
文件 294 2019-06-20 14:17 基于matplotlib的函数计算器\calculator\.idea\misc.xm
文件 279 2019-06-20 14:17 基于matplotlib的函数计算器\calculator\.idea\modules.xm
文件 55943 2019-07-01 19:14 基于matplotlib的函数计算器\calculator\.idea\workspace.xm
文件 14087 2019-07-01 19:10 基于matplotlib的函数计算器\calculator\Latex.py
文件 3355 2019-06-29 16:04 基于matplotlib的函数计算器\calculator\LatexMatrix.py
文件 262 2019-07-01 14:08 基于matplotlib的函数计算器\calculator\Main.py
目录 0 2020-01-09 17:26 基于matplotlib的函数计算器\calculator\__pycache__\
文件 8350 2019-07-01 19:11 基于matplotlib的函数计算器\calculator\__pycache__\Latex.cpython-37.pyc
文件 2591 2019-06-29 16:04 基于matplotlib的函数计算器\calculator\__pycache__\LatexMatrix.cpython-37.pyc
文件 10773 2019-07-01 16:43 基于matplotlib的函数计算器\calculator\__pycache__\controler.cpython-37.pyc
文件 5953 2019-06-29 15:38 基于matplotlib的函数计算器\calculator\__pycache__\viewMatrix.cpython-37.pyc
文件 20396 2019-07-01 16:48 基于matplotlib的函数计算器\calculator\__pycache__\viewPlot.cpython-37.pyc
文件 14392 2019-07-01 16:43 基于matplotlib的函数计算器\calculator\controler.py
文件 7100 2019-06-29 15:38 基于matplotlib的函数计算器\calculator\viewMatrix.py
文件 26768 2019-07-01 16:48 基于matplotlib的函数计算器\calculator\viewPlot.py
相关资源
- Python-BDD100K大规模多样化驾驶视频数据
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
评论
共有 条评论