From 2f60d0663d7f088535f2e60e5d0608ed0bdfca71 Mon Sep 17 00:00:00 2001 From: flatberg Date: Mon, 26 Feb 2007 09:08:50 +0000 Subject: [PATCH] Clean up of import statements --- fluents/plots.py | 59 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/fluents/plots.py b/fluents/plots.py index 809d53a..7fdb4a8 100644 --- a/fluents/plots.py +++ b/fluents/plots.py @@ -1,29 +1,30 @@ -import os,sys,copy +import os,sys from itertools import izip + import pygtk import gobject import gtk -import fluents -import logger + import matplotlib -from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas -from matplotlib.backend_bases import NavigationToolbar2,cursors -from matplotlib.backends.backend_gtk import FileChooserDialog -from matplotlib.nxutils import points_inside_poly -from matplotlib.axes import Subplot, AxesImage -from matplotlib.figure import Figure from matplotlib import cm,cbook -from pylab import Polygon, axis, Circle +from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg +from matplotlib.nxutils import points_inside_poly +from matplotlib.axes import Subplot +from matplotlib.figure import Figure from matplotlib.collections import LineCollection -from matplotlib.patches import Polygon,Rectangle +from matplotlib.patches import Polygon,Rectangle, Circle from matplotlib.lines import Line2D from matplotlib.mlab import prctile import networkx import scipy +import fluents +import logger + # global active mode. Used by toolbars to communicate correct mode active_mode = 'default' + class ObjectTable: """A 2D table of elements. An ObjectTable is a resizable two-dimensional array of objects. @@ -419,7 +420,7 @@ class Plot (View): logger.log('debug', 'plot %s init' %title) self.selection_listener = None self.fig = Figure() - self.canvas = FigureCanvas(self.fig) + self.canvas = FigureCanvasGTKAgg(self.fig) self._toolbar = PlotToolbar(self) self.canvas.add_events(gtk.gdk.ENTER_NOTIFY_MASK) self.current_dim = None @@ -830,13 +831,13 @@ class ScatterPlot(Plot): index = self.get_index_from_selection(self.dataset_1, selection) if len(index) > 0: linewidth.put(2, index) - self.sc.set_linewidth(linewidth) + self.selection_collection.set_linewidth(linewidth) if self.use_blit and len(index)>0 : if self._background is None: self._background = self.canvas.copy_from_bbox(self.axes.bbox) self.canvas.restore_region(self._background) - self.axes.draw_artist(self.sc) + self.axes.draw_artist(self.selection_collection) self.canvas.blit() else: self.canvas.draw() @@ -1088,7 +1089,6 @@ class NetworkPlot(Plot): xys.append((x,y)) c+=1 - self.canvas.draw_idle() index = scipy.nonzero(points_inside_poly(xys, verts))[0] ids = [node_ids[i] for i in index] ids = self.update_selection(ids, key) @@ -1137,21 +1137,22 @@ class NetworkPlot(Plot): class VennPlot(Plot): def __init__(self, name="Venn diagram"): Plot.__init__(self, name) - self._ax = self.fig.add_subplot(111) - self._ax.grid(0) + self.axes = self.fig.add_subplot(111) + self.axes.grid(0) self._init_bck() for c in self._venn_patches: - self._ax.add_patch(c) + self.axes.add_patch(c) for mrk in self._markers: - self._ax.add_patch(mrk) - self._ax.set_xlim([-3, 3]) - self._ax.set_ylim([-2.5, 3.5]) + self.axes.add_patch(mrk) + self.axes.set_xlim([-3, 3]) + self.axes.set_ylim([-2.5, 3.5]) self._last_active = set() - self._ax.set_xticks([]) - self._ax.set_yticks([]) - self._ax.grid(0) - self._ax.axis('equal') - self._ax.set_frame_on(False) + self.axes.set_xticks([]) + self.axes.set_yticks([]) + self.axes.grid(0) + self.axes.axis('equal') + self.axes.set_frame_on(False) + # add canvas to widget self.add(self.canvas) self.canvas.show() @@ -1195,7 +1196,7 @@ class VennPlot(Plot): self._tot_label = 'Tot: ' + str(len(self.all_elements)) self._sel_label = 'Sel: ' + str(len(self.active_elements)) - self._legend = self._ax.legend((self._tot_label, self._sel_label), + self._legend = self.axes.legend((self._tot_label, self._sel_label), loc='upper right') def set_selection(self, selection, patch=None): @@ -1246,7 +1247,7 @@ class VennPlot(Plot): self._last_active = self.active_elements.copy() self._sel_label = 'Sel: ' + str(len(self.active_elements)) self._legend.texts[1].set_text(self._sel_label) - self._ax.figure.canvas.draw() + self.axes.figure.canvas.draw() def rectangle_select_callback(self, x1, y1, x2, y2, key): """event1 and event2 are the press and release events""" @@ -1288,7 +1289,7 @@ class VennPlot(Plot): self._last_active = self.active_elements.copy() self._sel_label = 'Sel: ' + str(len(self.active_elements)) self._legend.texts[1].set_text(self._sel_label) - self._ax.figure.canvas.draw() + self.axes.figure.canvas.draw() def _patches_within_verts(self, verts, key): xy = scipy.array(verts).mean(0)