diff --git a/mapgenerator/__init__.py b/mapgenerator/__init__.py index 41b1c3f79e507af9b94bffc16d4c9535e6f3b8af..c3c8e3fc50bf24974bd9bc56b6f5a04caed2e025 100644 --- a/mapgenerator/__init__.py +++ b/mapgenerator/__init__.py @@ -1,4 +1,4 @@ """ Map Generator is a toolkit that provides easy to use 2D plotting and evaluation functions for Earth Sciences """ -__version__ = "1.0.2" +__version__ = "1.0.3" diff --git a/mapgenerator/plotting/plotmap.py b/mapgenerator/plotting/plotmap.py index 037df997aa2d772a5c2bd8e8cd0cfba9fadd407c..8fcae03c013ab371819738a83a0ac2818a75ebea 100644 --- a/mapgenerator/plotting/plotmap.py +++ b/mapgenerator/plotting/plotmap.py @@ -196,6 +196,8 @@ class PlotMap(MapCross, MapDrawOptions): def set_color_bar(self, mco, location='right', drawedges=False, cax=None): """ Create color bar """ + if not location: + return mpl.rcParams['axes.linewidth'] = 0.1 mpl.rcParams['axes.formatter.useoffset'] = False if self.ticks: @@ -203,25 +205,39 @@ class PlotMap(MapCross, MapDrawOptions): self.ticks = parse_parameters_list(self.ticks) elif self.bounds: self.ticks = self.bounds + while len(self.ticks) > 10: + self.ticks = self.ticks[0::2] elif hasattr(mco, 'levels'): self.ticks = mco.levels LOG.debug("***** Formats: %s *****", self.formats) - pad = {'bottom': 0.05, 'right': 0.02} - pad = pad.get(location, 0.02) - cax, kwargs = mpl.colorbar.make_axes(self.mgaxis, - location=location, - pad=pad, - shrink=0.9) - cbar = self.mgplot.colorbar(mco, - cax=cax, - ax=self.mgaxis, - ticks=self.ticks, - format=self.formats, - pad=.06, - extend=self.extend, - drawedges=drawedges, - **kwargs) + if self.subplot: + orientation = { + 'right': 'vertical', + 'bottom': 'horizontal', + } + cbar = self.mgplot.colorbar(mco, + ax=self.mgaxis, + ticks=self.ticks, + format=self.formats, + pad=.15, + drawedges=drawedges, + orientation=orientation[location]) + else: + pad = {'bottom': 0.05, 'right': 0.02} + pad = pad.get(location, 0.02) + cax, kwargs = mpl.colorbar.make_axes(self.mgaxis, + location=location, + pad=pad, + shrink=0.9) + cbar = self.mgplot.colorbar(mco, + cax=cax, + ax=self.mgaxis, + ticks=self.ticks, + format=self.formats, + pad=.06, + drawedges=drawedges, + **kwargs) cbar.ax.tick_params(labelsize=float(self.coordsopts[1])) for lin in cbar.ax.yaxis.get_ticklines(): lin.set_visible(False) @@ -583,8 +599,8 @@ class PlotMap(MapCross, MapDrawOptions): ) if self.draw_labels and bool(self.projection == 'PlateCarree'): - grl.xlabels_top = False - grl.ylabels_right = False + grl.top_labels = False + grl.right_labels = False if self.draw_labels: grl.xlabel_style = {'size': float(self.coordsopts[1])} grl.ylabel_style = grl.xlabel_style @@ -860,8 +876,10 @@ class PlotMap(MapCross, MapDrawOptions): else: self.mgaxis = plt.subplot(self.subplot[0], self.subplot[1], - self.subplot[3], - projection=self._crs) + self.subplot[2], + projection=self._crs, + sharex=True, + sharey=True,) self.mgplot = plt.gcf() valid_tmp = dims[n_time] diff --git a/mapgenerator/plotting/timeseries.py b/mapgenerator/plotting/timeseries.py index 045ced72af8828dfb732b9fa91025c771e1fa0a8..57c097c2ec3d77becfc80307452a5915f23058cd 100644 --- a/mapgenerator/plotting/timeseries.py +++ b/mapgenerator/plotting/timeseries.py @@ -307,9 +307,4 @@ class DateFormatter(ticker.Formatter): self.fmt = fmt def __call__(self, x, pos=0): - if x == 0: - raise ValueError('DateFormatter found a value of x=0, which is ' - 'an illegal date; this usually occurs because ' - 'you have not informed the axis that it is ' - 'plotting dates, e.g., with ax.xaxis_date()') return self.units.num2date(x).strftime(self.fmt)