说明:
关于matplotlib,其实网上的很多代码,不清楚它的一些函数用法。如:polar中的用法,可以找到matplotlib官网,找到pyplot菜单链接,搜索类名称,再找到pyplot链接下相关绘图函数或类
polar,按Ctrl键+F键搜索polar或其它函数名称。
The Pyplot API — Matplotlib 2.2.2 documentation https://matplotlib.org/api/pyplot_summary.html(还得要阅读官方文档,基本都全了,如pyplot,doc等)
matplotlib的基本用法(十四)——figure图的嵌套 - CSDN博客 https://blog.csdn.net/quincuntial/article/details/71178116
python 实现将 pandas 数据和 matplotlib 绘图嵌入 html 文件 - CSDN博客 https://blog.csdn.net/XnCSD/article/details/79231205
在qt5中嵌入matplotlib - 阿拉果 - 博客园(可以入门看看) https://www.cnblogs.com/Arago/p/7765510.html
python matplotlib中axes与axis的区别? - 知乎 https://www.zhihu.com/question/51745620
Seaborn(sns)官方文档学习笔记(第一章 艺术化的图表控制) https://zhuanlan.zhihu.com/p/27435863
from numpy import arange, sin, pi
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
class MyMplCanvas(FigureCanvas):
#"""这是一个窗口部件,即QWidget(当然也是FigureCanvasAgg)"""
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
# 每次plot()调用的时候,我们希望原来的坐标轴被清除(所以False)
self.axes.hold(False)
self.compute_initial_figure()
FigureCanvas.__init__(self, fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,QSizePolicy.Expanding,QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
def compute_initial_figure(self):
pass
class MyStaticMplCanvas(MyMplCanvas):
"""静态画布:一条正弦线"""
def compute_initial_figure(self):
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
self.axes.plot(t, s)