Skip to content

Commit

Permalink
Add utility func to DataLevels (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Apr 17, 2017
1 parent 5f12747 commit dc2f5ac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions salem/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,17 @@ def to_rgb(self):

return self.cmap(self.norm(self.data))

def get_colorbarbase_kwargs(self):
"""If you need to make a colorbar based on a given DataLevel state."""

# This is a discutable choice: with more than 60 colors (could be
# less), we assume a continuous colorbar.
if self.nlevels < 60:
norm = self.norm
else:
norm = mpl.colors.Normalize(vmin=self.vmin, vmax=self.vmax)
return dict(extend=self.extend, cmap=self.cmap, norm=norm)

def colorbarbase(self, cax, **kwargs):
"""Returns a ColorbarBase to add to the cax axis. All keywords are
passed to matplotlib.colorbar.ColorbarBase
Expand Down

0 comments on commit dc2f5ac

Please sign in to comment.