Repository: climate Updated Branches: refs/heads/master b8c3503c7 -> 41d4d0751
CLIMATE-466 - Update plotter for better colorbar - Update colorbar range to ensure that 0 is centered when there's a 0 value. Previously when the value range crossed 0 it was possible to end up with a range where 0 was pushed very far to one side. It's more convenient to analyze a graph when the 0 value is centered in the color spectrum. Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/c842a3b3 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/c842a3b3 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/c842a3b3 Branch: refs/heads/master Commit: c842a3b31a7aafdbd6268e62d1d50663275148ef Parents: b8c3503 Author: Maziyar Boustani <[email protected]> Authored: Fri Jun 6 15:18:45 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Wed Jun 11 07:58:45 2014 -0700 ---------------------------------------------------------------------- ocw/plotter.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/c842a3b3/ocw/plotter.py ---------------------------------------------------------------------- diff --git a/ocw/plotter.py b/ocw/plotter.py index 33a1bd1..07498df 100644 --- a/ocw/plotter.py +++ b/ocw/plotter.py @@ -61,8 +61,20 @@ def _nice_intervals(data, nlevs): # Find the min and max levels by cutting off the tails of the distribution # This mitigates the influence of outliers data = data.ravel() - mnlvl = mstats.scoreatpercentile(data, 5) - mxlvl = mstats.scoreatpercentile(data, 95) + mn = mstats.scoreatpercentile(data, 5) + mx = mstats.scoreatpercentile(data, 95) + #if there min less than 0 and + # or max more than 0 + #put 0 in center of color bar + if mn < 0 and mx > 0: + level = max(abs(mn), abs(mx)) + mnlvl = -1 * level + mxlvl = level + #if min is larger than 0 then + #have color bar between min and max + else: + mnlvl = mn + mxlvl = mx locator = mpl.ticker.MaxNLocator(nlevs) clevs = locator.tick_values(mnlvl, mxlvl) @@ -71,6 +83,7 @@ def _nice_intervals(data, nlevs): clevs = clevs[(clevs >= mnlvl) & (clevs <= mxlvl)] return clevs + def _best_grid_shape(nplots, oldshape): ''' Purpose::
