def _configure_pre(self): # configure plotlib plt.clf() plt.close('all') self.f = self._get('f', 10, float) if 'map' in self.m: self.f *= 0.8 # smaller font if plotting map plt.rc( 'font', **{ 'family': 'sans-serif', 'sans-serif': ['Dejavu Sans'], 'size': self.f }) # plt.rc('axes', grid = True) plt.rc('lines', markeredgewidth=0) w = self._get('w', 25, float) h = self._get('h', w / np.sqrt(2), float) # convert cm to inches w = w / 2.54 h = h / 2.54 self.w = w self.h = h plt.gcf().set_size_inches([w, h], forward=True) # f = 0.09 # if 'map' in self.m: f = 0.06 # more margin if plotting map # plt.gca().set_position([f, f, 1 - 2 * f, 1 - 2 * f]) # plt.subplots_adjust(left = f, bottom = f, right = 1 - f, top = 1 - f, wspace = 0, hspace = 0) ticks.set_extended_locator(self.__tick_density) self.axes[''] = plt.gca()
def selectAxes(self, i): plt.axes(self.axes['']) # activate main axes v = self.tw[i] if v and v in 'xy': if v in self.axes: plt.axes(self.axes[v]) # activate twin x/y axes else: self.axes[v] = self.__twin[v]() # create twin x/y axes ticks.set_extended_locator(self.__tick_density) # add tick locator return
def _configure_pre(self): # configure plotlib plt.clf() plt.close('all') self.f = self._get('f', 10, float) if 'map' in self.m: self.f *= 0.8 # smaller font if plotting map plt.rc('font', **{'family':'sans-serif', 'sans-serif':['Dejavu Sans'], 'size':self.f}) # plt.rc('axes', grid = True) plt.rc('lines', markeredgewidth = 0) w = self._get('w', 25, float) h = self._get('h', w / np.sqrt(2), float) # convert cm to inches w = w / 2.54 h = h / 2.54 self.w = w self.h = h plt.gcf().set_size_inches([w, h], forward = True); # f = 0.09 # if 'map' in self.m: f = 0.06 # more margin if plotting map # plt.gca().set_position([f, f, 1 - 2 * f, 1 - 2 * f]) # plt.subplots_adjust(left = f, bottom = f, right = 1 - f, top = 1 - f, wspace = 0, hspace = 0) ticks.set_extended_locator(self.__tick_density) self.axes[''] = plt.gca()
x, y = m(lo, la) m.plot(x, y, 'rs', markersize = 4) plt.annotate(name, (x, y), textcoords = 'offset points', xytext = (5, 2)) sys.stdout = sys.__stdout__ return m if __name__ == '__main__': import tables import matplotlib.mlab as mlab plt.rc('font', **{'family':'sans-serif', 'sans-serif':['Dejavu Sans'], 'size':10}) plt.rc('axes', grid = True) plt.rc('lines', markeredgewidth = 0) ticks.set_extended_locator(1) plotwidth = 12 plt.gcf().set_size_inches((plotwidth, plotwidth / np.sqrt(2))); f = 0.09 plt.gca().set_position([f, f, 1 - 2 * f, 1 - 2 * f]) f = tables.openFile('data/x-dwd.h5', 'r') zvalue = 'tm' time = set() zmin = np.inf zmax = -np.inf data_table = f.root.raw.weather for row in data_table: time.add(row['time']) zmin, zmax = min(zmin, row[zvalue]), max(zmax, row[zvalue])
return m if __name__ == '__main__': import tables import matplotlib.mlab as mlab plt.rc( 'font', **{ 'family': 'sans-serif', 'sans-serif': ['Dejavu Sans'], 'size': 10 }) plt.rc('axes', grid=True) plt.rc('lines', markeredgewidth=0) ticks.set_extended_locator(1) plotwidth = 12 plt.gcf().set_size_inches((plotwidth, plotwidth / np.sqrt(2))) f = 0.09 plt.gca().set_position([f, f, 1 - 2 * f, 1 - 2 * f]) f = tables.openFile('data/x-dwd.h5', 'r') zvalue = 'tm' time = set() zmin = np.inf zmax = -np.inf data_table = f.root.raw.weather for row in data_table: time.add(row['time']) zmin, zmax = min(zmin, row[zvalue]), max(zmax, row[zvalue])