Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
<author email="mabel@openrobotics.org">Mabel Zhang</author>
<author email="logans@cottsay.net">Scott K Logan</author>

<build_depend>qt-base-dev</build_depend>
<build_depend>libqtwidgets</build_depend>

<exec_depend>ament_index_python</exec_depend>
<exec_depend version_gte="0.2.19">python_qt_binding</exec_depend>
<exec_depend>python3-matplotlib</exec_depend>
Expand Down
24 changes: 3 additions & 21 deletions src/rqt_plot/data_plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import numpy

from python_qt_binding import QT_BINDING
from python_qt_binding.QtCore import qWarning, Signal
from python_qt_binding.QtGui import QColor, QColorConstants
from python_qt_binding.QtWidgets import QHBoxLayout, QWidget
Expand All @@ -46,11 +45,6 @@
except ImportError:
MatDataPlot = None

try:
from .qwt_data_plot import QwtDataPlot
except ImportError:
QwtDataPlot = None

# separate class for DataPlot exceptions, just so that users can differentiate
# errors from the DataPlot widget from exceptions generated by the underlying
# libraries
Expand All @@ -66,7 +60,7 @@ class DataPlot(QWidget):

The DataPlot widget displays a plot, on one of several plotting backends,
depending on which backend(s) are available at runtime. It currently
supports PyQtGraph, MatPlot and QwtPlot backends.
supports PyQtGraph and MatPlot backends.

The DataPlot widget manages the plot backend internally, and can save
and restore the internal state using `save_settings` and `restore_settings`
Expand All @@ -93,14 +87,6 @@ class DataPlot(QWidget):
'PySide: PySide > 1.1.0\n',
'enabled': MatDataPlot is not None,
},
{
'title': 'QwtPlot',
'widget_class': QwtDataPlot,
'description':
'Based on QwtPlot\n- does not use timestamps\n- uses least CPU\n- needs Python '
'Qwt bindings\n',
'enabled': QwtDataPlot is not None,
},
]

# pre-defined colors:
Expand Down Expand Up @@ -148,13 +134,9 @@ def __init__(self, parent=None):

enabled_plot_types = [pt for pt in self.plot_types if pt['enabled']]
if not enabled_plot_types:
# minimum matplotlib version for Qt 5
version_info = '1.4.0'
if QT_BINDING == 'pyside':
version_info += ' and PySide 2.0.0'
raise RuntimeError(
'No usable plot type found. Install at least one of: PyQtGraph, MatPlotLib '
f'(at least {version_info}) or Python-Qwt5.')
'No usable plot type found. '
'Install at least one of: PyQtGraph, MatPlotLib.')

self._switch_data_plot_widget(self._plot_index)

Expand Down
50 changes: 13 additions & 37 deletions src/rqt_plot/data_plot/mat_data_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,18 @@
import operator

import matplotlib
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure

from python_qt_binding import QT_BINDING, QT_BINDING_VERSION, QtWidgets

try:
from pkg_resources import parse_version
except ImportError:
import re

def parse_version(s):
return [int(x) for x in re.sub(r'(\.0+)*$', '', s).split('.')]

if QT_BINDING == 'pyside':
qt_binding_version = QT_BINDING_VERSION.replace('~', '-')
if parse_version(qt_binding_version) <= parse_version('1.1.2'):
raise ImportError('A PySide version newer than 1.1.0 is required.')

from python_qt_binding.QtCore import Signal
from python_qt_binding.QtGui import QColorConstants
from python_qt_binding.QtWidgets import QVBoxLayout, QWidget

if QT_BINDING == 'pyside':
if parse_version(matplotlib.__version__) < parse_version('2.1.0'):
raise ImportError('A newer matplotlib is required (at least 2.1.0 for PySide 2)')
if parse_version(matplotlib.__version__) < parse_version('1.4.0'):
raise ImportError('A newer matplotlib is required (at least 1.4.0 for Qt 5)')
try:
matplotlib.use('Qt5Agg')
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
except ImportError:
# work around bug in dateutil
import sys
import thread
sys.modules['_thread'] = thread
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
matplotlib.use('QtAgg')

from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas # noqa: E402
from matplotlib.backends.backend_qtagg import NavigationToolbar2QT as NavigationToolbar # noqa: E402,E501
from matplotlib.figure import Figure # noqa: E402

from packaging.version import Version # noqa: E402

from python_qt_binding import QtWidgets # noqa: E402
from python_qt_binding.QtCore import Signal # noqa: E402
from python_qt_binding.QtGui import QColorConstants # noqa: E402
from python_qt_binding.QtWidgets import QVBoxLayout, QWidget # noqa: E402


class MatDataPlot(QWidget):
Expand Down Expand Up @@ -101,7 +77,7 @@ def safe_tight_layout(self):
return
self.figure.tight_layout()
except ValueError:
if parse_version(matplotlib.__version__) >= parse_version('2.2.3'):
if Version(matplotlib.__version__) >= Version('2.2.3'):
raise

limits_changed = Signal()
Expand Down
20 changes: 0 additions & 20 deletions src/rqt_plot/data_plot/pyqtgraph_data_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,6 @@
from python_qt_binding.QtGui import QColor, QColorConstants
from python_qt_binding.QtWidgets import QVBoxLayout, QWidget

try:
from pkg_resources import parse_version
except ImportError:
import re

def parse_version(s):
return [int(x) for x in re.sub(r'(\.0+)*$', '', s).split('.')]

try:
from pyqtgraph import __version__ as pyqtgraph_version
except RuntimeError:
# pyqtgraph < 1.0 using Qt4 failing on 16.04 because kinetic uses Qt5.
# This raises RuntimeError('the PyQt4.QtCore and PyQt5.QtCore modules both
# wrap the QObject class')
import pkg_resources
pyqtgraph_version = pkg_resources.get_distribution('pyqtgraph').version

if parse_version(pyqtgraph_version) < parse_version('0.10.0'):
raise ImportError('A newer PyQtGraph version is required (at least 0.10 for Qt 5)')


class PyQtGraphDataPlot(QWidget):

Expand Down
Loading