STY: Refactor MatplotlibCanvas from ImageCanvas and PlotCanvas.

This commit is contained in:
Tony S Yu
2012-07-27 21:57:46 -04:00
parent 9285898d39
commit 539b12dc2c
3 changed files with 22 additions and 23 deletions
+3 -11
View File
@@ -2,12 +2,12 @@ import numpy as np
from PyQt4 import QtGui
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from ..utils import MatplotlibCanvas
from .base import Plugin
class PlotCanvas(FigureCanvasQTAgg):
class PlotCanvas(MatplotlibCanvas):
"""Canvas for displaying images.
This canvas derives from Matplotlib, and has attributes `fig` and `ax`,
@@ -15,17 +15,9 @@ class PlotCanvas(FigureCanvasQTAgg):
"""
def __init__(self, parent, height, width, **kwargs):
self.fig, self.ax = plt.subplots(figsize=(height, width), **kwargs)
FigureCanvasQTAgg.__init__(self, self.fig)
FigureCanvasQTAgg.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvasQTAgg.updateGeometry(self)
# Note: `setParent` must be called after `FigureCanvasQTAgg.__init__`.
self.setParent(parent)
super(PlotCanvas, self).__init__(parent, self.fig, **kwargs)
self.setMinimumHeight(150)
class PlotPlugin(Plugin):
"""Plugin for ImageViewer that contains a plot canvas.