[hdf-compass] 212/295: add a colorbar to the ContourPlotFrame

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Sun May 8 10:35:46 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository hdf-compass.

commit fca656dc8ddd3bead84fe7beb474cd0f2ecc4618
Author: giumas <giumas at yahoo.it>
Date:   Mon Nov 2 15:42:32 2015 -0500

    add a colorbar to the ContourPlotFrame
---
 hdf_compass/compass_viewer/array/plot.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hdf_compass/compass_viewer/array/plot.py b/hdf_compass/compass_viewer/array/plot.py
index 5fe1e80..1112582 100644
--- a/hdf_compass/compass_viewer/array/plot.py
+++ b/hdf_compass/compass_viewer/array/plot.py
@@ -90,6 +90,7 @@ class ContourPlotFrame(PlotFrame):
     def __init__(self, data, names=None, title="Contour Plot"):
         # need to be set before calling the parent (need for plotting)
         self.colormap = "jet"
+        self.cb = None  # matplotlib color-bar
 
         PlotFrame.__init__(self, data, title)
 
@@ -159,5 +160,10 @@ class ContourPlotFrame(PlotFrame):
         data = self.data[::row_stride, ::col_stride]
         xx = np.arange(0, self.data.shape[1], col_stride)
         yy = np.arange(0, self.data.shape[0], row_stride)
-        out = self.axes.contourf(xx, yy, data, 25, cmap=plt.cm.get_cmap(self.colormap))
-        plt.colorbar(out)
+        img = self.axes.contourf(xx, yy, data, 25, cmap=plt.cm.get_cmap(self.colormap))
+        self.axes.set_aspect('equal')
+        if self.cb:
+            self.cb.on_mappable_changed(img)
+        else:
+            self.cb = plt.colorbar(img, ax=self.axes)
+        self.cb.ax.tick_params(labelsize=8)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/hdf-compass.git



More information about the debian-science-commits mailing list