E667 WIP: Contour log extension by efiring · Pull Request #8834 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

WIP: Contour log extension #8834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ENH: support extend kwarg with LogNorm in contourf
  • Loading branch information
efiring committed May 30, 2018
commit 8064a81655e893f8e461d709192db0d03707096b
18 changes: 12 additions & 6 deletions lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,10 +1245,19 @@ def _process_levels(self):
# (Colorbar needs this even for line contours.)
self._levels = list(self.levels)

if self.logscale:
raised = lambda x: x * 1.1
lowered = lambda x: x / 1.1
else:
raised = lambda x: x + 1
lowered = lambda x: x - 1

if self.extend in ('both', 'min'):
self._levels.insert(0, min(self.levels[0], self.zmin) - 1)
lower = lowered(min(self.levels[0], self.zmin))
self._levels.insert(0, lower)
if self.extend in ('both', 'max'):
self._levels.append(max(self.levels[-1], self.zmax) + 1)
upper = raised(max(self.levels[-1], self.zmax))
self._levels.append(upper)
self._levels = np.asarray(self._levels)

if not self.filled:
Expand All @@ -1260,10 +1269,7 @@ def _process_levels(self):
# ...except that extended layers must be outside the
# normed range:
if self.extend in ('both', 'min'):
if self.logscale:
self.layers[0] = 1e-150
else:
self.layers[0] = -1e150
self.layers[0] = 1e-150 if self.logscale else -1e150
if self.extend in ('both', 'max'):
self.layers[-1] = 1e150

Expand Down
0