技术标签: FigureCanvasQTagg # PyQt5知道这些就够了 backend_qt5agg matplotlib backends # 小白学Python
matplotlib:一个绘图用的Python模块
backends:matplotlib中的一个模块,后端。
backend_qt5agg:backends里面的一个模块,里面有两个类:FigureCanvasQTAgg
和_BackendQT5Agg
FigureCanvasQTagg:backend_qt5agg里的一个类
matplotlib绘制的图可以应用在PyQt5应用里面,下面三个import都需要:
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
**matplotlib.backends.backend_qt5agg用来连接Matplotlib和PyQt5。**backend_qt5agg.py的原文如下:
"""
Render to qt from agg.
"""
import ctypes
from matplotlib.transforms import Bbox
from .. import cbook
from .backend_agg import FigureCanvasAgg
from .backend_qt5 import (
QtCore, QtGui, QtWidgets, _BackendQT5, FigureCanvasQT, FigureManagerQT,
NavigationToolbar2QT, backend_version)
from .qt_compat import QT_API
class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT):
def __init__(self, figure):
# Must pass 'figure' as kwarg to Qt base class.
super().__init__(figure=figure)
def paintEvent(self, event):
"""Copy the image from the Agg canvas to the qt.drawable.
In Qt, all drawing should be done inside of here when a widget is
shown onscreen.
"""
if self._update_dpi():
# The dpi update triggered its own paintEvent.
return
self._draw_idle() # Only does something if a draw is pending.
# If the canvas does not have a renderer, then give up and wait for
# FigureCanvasAgg.draw(self) to be called.
if not hasattr(self, 'renderer'):
return
painter = QtGui.QPainter(self)
rect = event.rect()
left = rect.left()
top = rect.top()
width = rect.width()
height = rect.height()
# See documentation of QRect: bottom() and right() are off by 1, so use
# left() + width() and top() + height().
bbox = Bbox(
[[left, self.renderer.height - (top + height * self._dpi_ratio)],
[left + width * self._dpi_ratio, self.renderer.height - top]])
reg = self.copy_from_bbox(bbox)
buf = cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
memoryview(reg))
# clear the widget canvas
painter.eraseRect(rect)
qimage = QtGui.QImage(buf, buf.shape[1], buf.shape[0],
QtGui.QImage.Format_ARGB32_Premultiplied)
if hasattr(qimage, 'setDevicePixelRatio'):
# Not available on Qt4 or some older Qt5.
qimage.setDevicePixelRatio(self._dpi_ratio)
origin = QtCore.QPoint(left, top)
painter.drawImage(origin / self._dpi_ratio, qimage)
# Adjust the buf reference count to work around a memory
# leak bug in QImage under PySide on Python 3.
if QT_API in ('PySide', 'PySide2'):
ctypes.c_long.from_address(id(buf)).value = 1
self._draw_rect_callback(painter)
painter.end()
def blit(self, bbox=None):
"""Blit the region in bbox.
"""
# If bbox is None, blit the entire canvas. Otherwise
# blit only the area defined by the bbox.
if bbox is None and self.figure:
bbox = self.figure.bbox
# repaint uses logical pixels, not physical pixels like the renderer.
l, b, w, h = [pt / self._dpi_ratio for pt in bbox.bounds]
t = b + h
self.repaint(l, self.renderer.height / self._dpi_ratio - t, w, h)
def print_figure(self, *args, **kwargs):
super().print_figure(*args, **kwargs)
self.draw()
@_BackendQT5.export
class _BackendQT5Agg(_BackendQT5):
FigureCanvas = FigureCanvasQTAgg
一.概述CRNN(A C-LSTM Neural Network for Text Classification),是Chunting Zhou等提出的一种联合CNN和RNN的优点的混合神经网络,可称之为"卷积-递归"神经网络。 不同于RCNN先对文本句子上下文本信息、以及word-embedding本身特征的提取,CRNN中的CNN可以看成另外一种形式的句子信...
pyecharts的箱线图-基本版(1 of 3);组合版(2 of 3);加入时间线(3 of 3)配有动图 注释~大家可以一起学习讨论哦~
SQL_ID和PREV_SQL_ID在我们日常监控会话的SQL语句中非常重要,有时候我们经常看到SQL_ID是空的情况,那么我们就会去找 PREV_SQL_ID的值来获取最后一次执行的SQL语句.那么有一个疑问?什么时候SQL_ID有值,什么时候它又是空的呢?下面我们会来做一个小实验,我的实验环境是Oracle 11gR2.通过实验来说明这个问题.1.首先我们来模拟单会话查询;>>&g...
这一部分其实也算是今天的重点,这一部分用来回答很多群里的朋友所问过的问题,那就是我你是如何学习Java的,能不能给点建议? 今天我是打算来点干货,因此咱们就不说一些学习方法和技巧了,直接来谈每个阶段要学习的内容甚至是一些书籍。这一部分的内容,同样适用于一些希望转行到Java的同学。在大家看之前,我要先声明两点。1、由于我本人是Java后端开发出身,因此所推荐的学习内容是
00. 目录文章目录00. 目录01. 案例概述02. 开发环境03. 关键技术04. 程序设计05. 秘笈心法06. 源码下载07. 附录01. 案例概述本实例实现了工具栏上两个按钮互换位置的功能。运行程序如下图所示选择菜单“查看/改变按钮位置”,程序会将“新建”按钮和“保存”按钮进行位置调换,效果如下图所示。改变之前改变之后02. 开发环境系统环境:Windows 10开发环境:Visual Studio 201903. 关键技术本实例通过CToolBar 类的SetButton
Google Chrome Extension1. 可供查看的文档Google Extension的官方文档,https://developer.chrome.com/extensions/index.html详尽的说明,大量的例子,详尽的chrome API。国内有拿chromium开源project来开发的360极速浏览器,它的技术文档:http://open.
原文地址:http://blog.sina.com.cn/s/blog_46ee420b0100yi3g.html注:还未验证- -,先记录下来当用户登录网站时,一般要求用户提供登录该网站的用户名称和密码。从某种意义上说,密码的复杂程度越高,用户的信息安全性越高。因此,很多网站在注册用户信息或修改用户密码时,往往会提供一个密码强度的说明,从而提醒用户使用高强度的密码
Page与PageablePage是spring data jpa提供的一个接口。包含了部分数据集合以及相关的下一部分数据集合以及数据总数等信息。可以获得当前的页面的记录以及总页数和总数据数,以及数据是否能够再分页。PageImpl是Page接口的实现类。重写了 hashcode(),equals(),toString()方法。Pageable也是spring data jpa提供的接口,包含了分页的信息,页数getPageNumber()和每页的数据数getPageSzie()。以便JPA通过P
文章目录前言第一章一、填空题二、判断题三、选择题四、简答题第二章一、填空题二、判断题三、选择题四、简答题第三章一、填空题二、判断题三、选择题四、简答题第四章一、单选题二、判断题三、填空题四、程序分析题第五章一、选择题二、判断题三、填空题四、简答题五、程序分析题第六章一、单选题二、判断题三、填空题四、简答题五、程序分析题第七章一、...
基金分析工具箱(第一期)—— Morningstar主动/被动晴雨表 私募云通 fofpower https://mp.weixin.qq.com/s/DuvOf3mgpb1rB21WitqvTA注:有很多图,请看原文。3天前 文献来源:《Morningstar’s Active/Passive Barometer March 2018》推荐理由:这篇文章本质上是一份主动/...
解决办法:1.首先查看当前redis是否开启:ps -ef | grep redis-2.若上一步结果如下图所示,则首先直接杀死该进程;kill -s 9 13453.然后,重新开启redis服务redis-server redis.conf接下来就一切正常了,若还是无法解决,则选择重启redis所在的主机服务器。...
[APIO2016]划艇总共只有2*n段。分段进行DP简单的方法是:外层枚举段数j,f[i]表示,当前枚举到j的时候,以(i,j)结尾(必须选择(i,j))的方案数,枚举一个f(p,1~j-1)进行转移连续一段j区间,有包括i一共有m个可以选择的学校,那么这里贡献的方案数就是:∑(1<=i<=m)C(len,i)*C(m-1,i)=C(l+m-1,m)等式考虑用网...