8000 Handle nan/masked values Axes.vlines and hlines by phobson · Pull Request #7408 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Handle nan/masked values Axes.vlines and hlines #7408

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

Merged
merged 3 commits into from
Nov 8, 2016
Merged
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
Prev Previous commit
Next Next commit
Use builtin min/max in hlines/vlines
This is a little simpler since we're finding the min
or max of two scalars (avoids an intermediate list +
diving into numpy).

Also synced up the decorator between the two functions.
  • Loading branch information
phobson committed Nov 7, 2016
commit 61c214eb4d6c436d41023a09f005885de817e86c
15 changes: 8 additions & 7 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,8 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
self.autoscale_view(scaley=False)
return p

@_preprocess_data(replace_names=['y', 'xmin', 'xmax'], label_namer="y")
@_preprocess_data(replace_names=['y', 'xmin', 'xmax', 'colors'],
label_namer='y')
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
label='', **kwargs):
"""
Expand Down Expand Up @@ -986,8 +987,8 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
lines.update(kwargs)

if len(y) > 0:
minx = np.min([xmin.min(), xmax.min()])
maxx = np.max([xmin.max(), xmax.max()])
minx = min(xmin.min(), xmax.min())
maxx = max(xmin.max(), xmax.max())
miny = y.min()
maxy = y.max()

Expand All @@ -998,8 +999,8 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',

return lines

@_preprocess_data(replace_names=["x", "ymin", "ymax", "colors"],
label_namer="x")
@_preprocess_data(replace_names=['x', 'ymin', 'ymax', 'colors'],
label_namer='x')
def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
label='', **kwargs):
"""
Expand Down Expand Up @@ -1071,8 +1072,8 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
if len(x) > 0:
minx = x.min()
maxx = x.max()
miny = np.min([ymin.min(), ymax.min()])
maxy = np.max([ymin.max(), ymax.max()])
miny = min(ymin.min(), ymax.min())
maxy = max(ymin.max(), ymax.max())

corners = (minx, miny), (maxx, maxy)
self.update_datalim(corners)
Expand Down
0