[HP3562A] replace matplotlib with pytgraph

Wed, 16 May 2018 09:10:55 +0200

author
David Douard <david.douard@logilab.fr>
date
Wed, 16 May 2018 09:10:55 +0200
changeset 90
869de27dedc7
parent 89
61074a32808a
child 91
f2a8f688dbc0

[HP3562A] replace matplotlib with pytgraph

pygpibtoolkit/HP3562A/datablockwidget.py file | annotate | diff | comparison | revisions
pygpibtoolkit/qt5/mpl.py file | annotate | diff | comparison | revisions
setup.py file | annotate | diff | comparison | revisions
--- a/pygpibtoolkit/HP3562A/datablockwidget.py	Tue May 15 16:09:16 2018 +0200
+++ b/pygpibtoolkit/HP3562A/datablockwidget.py	Wed May 16 09:10:55 2018 +0200
@@ -20,8 +20,9 @@
 from PyQt5 import QtCore, QtWidgets
 from PyQt5.QtCore import Qt
 
+from pyqtgraph import PlotWidget
 
-from pygpibtoolkit.qt4.mpl import QMplCanvas, FigureCanvas
+#from pygpibtoolkit.qt5.mpl import QMplCanvas
 
 from pygpibtoolkit.HP3562A import state_decoder
 from pygpibtoolkit.HP3562A import trace_decoder
@@ -229,11 +230,13 @@
 
     def setupUI(self):
         self.setupToolBar()
-        self.canvas = QMplCanvas(self)
         super().setupUI()
         mainw = QtWidgets.QWidget(self)
         l = QtWidgets.QVBoxLayout(mainw)
         l.setContentsMargins(0, 0, 0, 0)
+        self.canvas = PlotWidget(self)
+        self.plot = self.canvas.plot()
+        self.canvas.showGrid(x=True, y=True)
         l.addWidget(self.canvas, 1)
 
         self.setCentralWidget(mainw)
@@ -248,19 +251,14 @@
             minv = min(y[y > 0])
             y[y == 0] = minv
             y = numpy.log10(y)
-            y = y*10
-        self.canvas.axes.clear()
-        self.canvas.axes.plot(x, y, 'r')
-        self.canvas.axes.set_xlim(min(x), max(x))
-        self.canvas.axes.set_xlabel("%s (%s)"%(self.header[0]['Domain'],
-                                               self.header[0]['X axis units']))
-        if self.ylogaction.isChecked():
-            self.canvas.axes.set_ylabel('db (%s)'%self.header[0]['Amplitude units'])
-        else:
-            self.canvas.axes.set_ylabel('%s'%self.header[0]['Amplitude units'])
-        self.canvas.axes.grid(True)
-        if self.header[0]['Display function']:
-            self.canvas.axes.set_title(self.header[0]['Display function'])
+            y = y * 10
+        self.plot.setData(x=x, y=y)
+        self.canvas.setLabel('bottom', self.header[0]['Domain'],
+                             units=self.header[0]['X axis units'])
+        yunit = 'dB' if self.ylogaction.isChecked() else ''
+        self.canvas.setLabel('left', self.header[0]['Amplitude units'],
+                             units=yunit)
+        self.canvas.setTitle(self.header[0]['Display function'])
 
         # compute THD, if any
         y = self.trace.copy()
@@ -285,9 +283,8 @@
         else:
             msg += 'THD+N:%.2g db  ' % thdn
         self.statusBar().showMessage(msg)
-        self.canvas.draw() 
-        
-        
+
+
 class CoordBinaryDatablockMDIChild(TraceBinaryDatablockMDIChild):
     _username = "Coord"
     _header_struct = (coord_decoder.TRACE_HEADER, coord_decoder.HEADER, )
@@ -323,20 +320,17 @@
 
         if self.header[1]['Y scale factor']:
             y *= self.header[1]['Y scale factor']
-        self.canvas.axes.clear()
-        self.canvas.axes.plot(x, y, 'r')
-        self.canvas.axes.set_xlim(min(x), max(x))
-        self.canvas.axes.set_xlabel("%s (%s)"%(self.header[0]['Domain'],
-                                               self.header[0]['X axis units']))
-        self.canvas.axes.set_ylabel('%s (%s)'%(self.header[1]['Y coordinates'],
-                                               self.header[0]['Amplitude units']))
-        self.canvas.axes.grid(True)
-        if self.header[0]['Display function']:
-            self.canvas.axes.set_title(self.header[0]['Display function'])
-        
-        self.canvas.draw() 
-        
-    
+        self.plot.setData(x=x, y=y)
+        self.canvas.setLabel(
+            'bottom', self.header[0]['Domain'],
+            units=self.header[0]['X axis units'])
+        self.canvas.setLabel(
+            'left', self.header[1]['Y coordinates'],
+            units=self.header[0]['Amplitude units'])
+        self.canvas.showGrid(x=True, y=True)
+        self.canvas.setTitle(self.header[0]['Display function'])
+
+
 children.append(CoordBinaryDatablockMDIChild)
 children.append(TraceBinaryDatablockMDIChild)
 children.append(StateBinaryDatablockMDIChild)
--- a/pygpibtoolkit/qt5/mpl.py	Tue May 15 16:09:16 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-# stolen from:
-# embedding_in_qt4.py --- Simple Qt4 application embedding matplotlib canvases
-#
-# Copyright (C) 2005 Florent Rougon
-#               2006 Darren Dale
-#
-# This file is an example program for matplotlib. It may be used and
-# modified with no restriction; raw copies as well as modified versions
-# may be distributed without limitation.
-
-""" Copyright (c) 2007-2018 David Douard (Paris, FRANCE).
-http://www.logilab.org/project/pygpibtoolkit -- mailto:david.douard@sdfa3.org
-"""
-
-from PyQt5 import QtCore, QtWidgets
-
-from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
-from matplotlib.figure import Figure
-
-
-class QMplCanvas(Canvas):
-    def __init__(self, parent=None, width=5, height=4, dpi=100):
-        self.fig = Figure(figsize=(width, height), dpi=dpi)
-        self.axes = self.fig.add_subplot(111)
-        # We want the axes cleared every time plot() is called
-        self.axes.hold(False)
-
-        super().__init__(self.fig)
-        self.setParent(parent)
-
-        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
-                           QtWidgets.QSizePolicy.Expanding)
-        self.updateGeometry()
-
-    def sizeHint(self):
-        w, h = self.get_width_height()
-        return QtCore.QSize(w, h)
-
-    def minimumSizeHint(self):
-        return QtCore.QSize(10, 10)
-
-    def plot(self, xdata, ydata, color="r"):
-        self.axes.plot(xdata, ydata, color)
-
-
-def main():
-    from PyQt5.QtWidgets import QApplication
-    app = QApplication([])
-    w = QMplCanvas()
-    w.plot([x for x in range(10)], [x*x for x in range(10)])
-    w.show()
-    app.exec_()
-
-
-if __name__ == '__main__':
-    main()
--- a/setup.py	Tue May 15 16:09:16 2018 +0200
+++ b/setup.py	Wed May 16 09:10:55 2018 +0200
@@ -6,7 +6,7 @@
       packages=find_packages(),
       version='0.1.0',
       install_requires=[
-          'pyserial', 'numpy', 'matplotlib'],
+          'pyserial', 'numpy', 'PyQt5', 'pyqtgraph'],
       entry_points={'console_scripts': [
           'pygpib-detect=pygpibtoolkit.detect:main',
           'hp3562-coord=pygpibtoolkit.HP3562A.coord_decoder:main',

mercurial

PK‡OLäø…ÔÍ.Ð8 ¤�whatever-9ba7fe3d0a22/content/images/hp3562a/a18_psu.jpgUTл…ZPK‡OLè,ß[\^A ¤�‡Íwhatever-9ba7fe3d0a22/content/images/hp3562a/a1_burst_control.pngUTл…ZPK‡OLÚqЯd? NA B ¤�)whatever-9ba7fe3d0a22/content/images/hp3562a/a1_digital_source.jpgUTл…ZPK‡OLr8ÕÂE B ¤�ôhwhatever-9ba7fe3d0a22/content/images/hp3562a/a1_digital_source.pngUTл…ZPK‡OLNgÓæN{RD ¤�²mwhatever-9ba7fe3d0a22/content/images/hp3562a/a1_phase_resolution.pngUTл…ZPK‡OL¼ š®-}àB ¤�½whatever-9ba7fe3d0a22/content/images/hp3562a/a1_timing_control.pngUTл…ZPK‡OLC < ¤�û¯5whatever-9ba7fe3d0a22/content/images/hp3562a/a31_trigger.jpgUTл…ZPK‡OLïˆÆØÍ` ¹b > ¤�óì@whatever-9ba7fe3d0a22/content/images/hp3562a/a32_input_adc.jpgUTл…ZPK‡OLáà ›öù÷A ¤�5NJwhatever-9ba7fe3d0a22/content/images/hp3562a/a32_input_adc_bb.jpgUTл…ZPK‡OLJi1 –Z˜: ¤�ÃDSwhatever-9ba7fe3d0a22/content/images/hp3562a/a33_input.jpgUTл…ZPK‡OL‡rrצA ¦C ; ¤�SÛYwhatever-9ba7fe3d0a22/content/images/hp3562a/a38_memory.jpgUTл…ZPK‡OL~ÇO­b¥e7 ¤�kewhatever-9ba7fe3d0a22/content/images/hp3562a/a3_rom.pngUTл…ZPK‡OLäÞ mõ Ñ 7 ¤�†€ewhatever-9ba7fe3d0a22/content/images/hp3562a/a4_loc.jpgUTл…ZPK‡OLé ªÓäçD ¤�éšpwhatever-9ba7fe3d0a22/content/images/hp3562a/a4_local_oscillator.pngUTл…ZPK‡OLÒ÷ SœBECD ¤�7€qwhatever-9ba7fe3d0a22/content/images/hp3562a/a5_a6_block_diagram.pngUTл…ZPK‡OLö:¼f;ÉíÌA ¤�NÃqwhatever-9ba7fe3d0a22/content/images/hp3562a/a5_block_diagram.pngUTл…ZPK‡OLÂw�ù]› 9� : ¤��rwhatever-9ba7fe3d0a22/content/images/hp3562a/a5_filter.jpgUTл…ZPK‡OLÝ$a@bA ¤�Ï(~whatever-9ba7fe3d0a22/content/images/hp3562a/a6_block_diagram.pngUTл…ZPK‡OL@‡ ¸ã÷ ¼ù ; ¤�kŠ~whatever-9ba7fe3d0a22/content/images/hp3562a/a6_control.jpgUTл…ZPK‡OL@‡ ¸ã÷ ¼ù > ¤�À‚Šwhatever-9ba7fe3d0a22/content/images/hp3562a/a6_controller.jpgUTл…ZPK‡OL`k1Ž18 ¤�{–whatever-9ba7fe3d0a22/content/images/hp3562a/a6_zoom.pngUTл…ZPK‡OLhµ�g6 48 7 ¤�‡¬–whatever-9ba7fe3d0a22/content/images/hp3562a/a7_fpp.jpgUTл…ZPK‡OL)‹dÜ@9L7 ¤�\ã¢whatever-9ba7fe3d0a22/content/images/hp3562a/a7_fpp.pngUTл…ZPK‡OL '&–êSU? ¤�¦$§whatever-9ba7fe3d0a22/content/images/hp3562a/a8_a17_display.pngUTл…ZPK‡OL‡ô éË Ð7 ¤�y§whatever-9ba7fe3d0a22/content/images/hp3562a/a8_ram.pngUTл…ZPK‡OLj;ÍÿÏs ¬u 7 ¤�]E¨whatever-9ba7fe3d0a22/content/images/hp3562a/a9_fft.jpgUTл…ZPK‡OLz‚8»ãðê7 ¤�š¹³whatever-9ba7fe3d0a22/content/images/hp3562a/a9_fft.pngUTл…ZPK‡OL”ýŽ­A�ª‘> ¤�"�´whatever-9ba7fe3d0a22/content/images/hp3562a/analog_source.pngUTл…ZPK‡OLZD ™CT> ¤�Ø,µwhatever-9ba7fe3d0a22/content/images/hp3562a/block_diagram.pngUTл…ZPK‡OLŠ*n§c8•<5 ¤��/¶whatever-9ba7fe3d0a22/content/images/hp3562a/caps.jpgUTл…ZPK‡OLé� „ƘP¦4 ¤�_h½whatever-9ba7fe3d0a22/content/images/hp3562a/cpu.jpgUTл…ZPK‡OL pC)òœø7 ¤��Àwhatever-9ba7fe3d0a22/content/images/hp3562a/filter.jpgUTл…ZPK‡OL—˜çl;z—|6 ¤�'ôÆwhatever-9ba7fe3d0a22/content/images/hp3562a/front.jpgUTл…ZPK‡OL‰+8- E; ¤�ÏnÎwhatever-9ba7fe3d0a22/content/images/hp3562a/front_open.jpgUTл…ZPK‡OLº;]‘öÒûÔ8 ¤�n{Öwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a.jpgUTл…ZPK‡OL´!eË?F ¤�ÓNßwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_block_diagram.pngUTл…ZPK‡OL2“ãŽøwB ¤�Tàwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_dead_caps.jpgUTл…ZPK‡OLꜛ` `G ¤�"Mäwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_ramp_generator.pngUTл…ZPK‡OLbL(EoEF ¤�;®åwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_raster_vector.pngUTл…ZPK‡OLÈl8ˆÙ  = ¤�Òóåwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_side.jpgUTл…ZPK‡OL­|‚ØwO{> ¤�ðwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_side2.jpgUTл…ZPK‡OL¾ÒÏV WI ¤�lxöwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_stroke_generator.pngUTл…ZPK‡OLÓ¶ŽüÐíéE ¤�»Ïøwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_test_pattern.pngUTл…ZPK‡OLþ4Onß…á< ¤�3¡whatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_top.jpgUTл…ZPK‡OL´c†ÙAuBI ¤��whatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_vector_processor.pngUTл…ZPK‡OLT+v®y”yI ¤�mÃwhatever-9ba7fe3d0a22/content/images/hp3562a/hp1345a_vpc_architecture.pngUTл…ZPK‡OLØ<Õç;£X¥J ¤�›=whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a15_block_diagram.pngUTл…ZPK‡OLH/Ö­›…N ¤�Wáwhatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a18_psu_block_diagram.pngUTл…ZPK‡OLo«£ž¿³j·I ¤�wâwhatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a1_block_diagram.pngUTл…ZPK‡OLÇæ,]n©oQ ¤�¶–whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a1_burst_control_circuit.pngUTл…ZPK‡OLRZçuœZ¡T ¤�› whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a1_phase_resolution_circuit.pngUTл…ZPK‡OL¾ðõ(¦�©R ¤�›¢ whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a1_timing_control_circuit.pngUTл…ZPK‡OL¹ÇÖbÇ�Q‡I ¤�LI!whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a2_block_diagram.pngUTл…ZPK‡OL%`gÖŒ…�J ¤�“Ë"whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a30_block_diagram.pngUTл…ZPK‡OL¼QyUyVÿ_J ¤�êX#whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a32_block_diagram.pngUTл…ZPK‡OL¢…×ÐÊùÉJ ¤�ä¯$whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a33_block_diagram.pngUTл…ZPK‡OLô'þÒŒ �Q ¤�/ª%whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a38_memory_block_diagram.pngUTл…ZPK‡OLyÚ raz%}N ¤�‰7'whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a38_ram_block_diagram.pngUTл…ZPK‡OLÓX^"«y{N ¤�o²'whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a38_rom_block_diagram.pngUTл…ZPK‡OL°F¼Á>ìCîI ¤�Ÿ,(whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a4_block_diagram.pngUTл…ZPK‡OL©¡Ë)/ܶÞI ¤�])whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a5_block_diagram.pngUTл…ZPK‡OL€ Ü×`rÜtI ¤� ö)whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a7_block_diagram.pngUTл…ZPK‡OL(Ñ£NÑÅÖI ¤�ìh+whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_a9_block_diagram.pngUTл…ZPK‡OLm,ÈÕþÔJ ¤�º:,whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_block_diagram_new.pngUTл…ZPK‡OLzÈ[VnêZêK ¤�:-whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_floating_input_amp.pngUTл…ZPK‡OLÚc6þKçÿO ¤�%.whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_hardware_block_diagram.pngUTл…ZPK‡OL Œ½³vÛNÛL ¤�Ñ%3whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_input_configuration.pngUTл…ZPK‡OLÙÕ:¢òM ¤�Ê5whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_throughput_data_flow.pngUTл…ZPK‡OLwIIû³ì³N ¤�m 7whatever-9ba7fe3d0a22/content/images/hp3562a/hp3562a_true_differential_amp.pngUTл…ZPK‡OL’©¨µ6 ¤�íÔ7whatever-9ba7fe3d0a22/content/images/hp3562a/input.pngUTл…ZPK‡OL&@<[ÕEÛ: ¤�Ö8whatever-9ba7fe3d0a22/content/images/hp3562a/input_adc.pngUTл…ZPKKK×#Ϋ9