Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Line2D._path obeys drawstyle.#6497

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
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
10 changes: 6 additions & 4 deletionslib/matplotlib/cbook.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2403,12 +2403,14 @@ def pts_to_midstep(x, *args):
# convert 2D array back to tuple
return tuple(steps)

STEP_LOOKUP_MAP = {'pre': pts_to_prestep,
STEP_LOOKUP_MAP = {'default': lambda x, y: (x, y),
'pre': pts_to_prestep,
'post': pts_to_poststep,
'mid': pts_to_midstep,
'step-pre': pts_to_prestep,
'step-post': pts_to_poststep,
'step-mid': pts_to_midstep}
'steps': pts_to_prestep,
'steps-pre': pts_to_prestep,
'steps-post': pts_to_poststep,
'steps-mid': pts_to_midstep}


def index_of(y):
Expand Down
45 changes: 6 additions & 39 deletionslib/matplotlib/lines.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,7 +17,7 @@
from . import artist, colors as mcolors
from .artist import Artist
from .cbook import (iterable, is_string_like, is_numlike, ls_mapper_r,
pts_to_prestep, pts_to_poststep, pts_to_midstep)
STEP_LOOKUP_MAP)

from .path import Path
from .transforms import Bbox, TransformedPath, IdentityTransform
Expand DownExpand Up@@ -237,6 +237,7 @@ class Line2D(Artist):
'steps': '_draw_steps_pre',
}

# drawStyles should now be deprecated.
drawStyles = {}
drawStyles.update(_drawStyles_l)
drawStyles.update(_drawStyles_s)
Expand DownExpand Up@@ -470,8 +471,7 @@ def contains(self, mouseevent):
# application has set the error flags such that an exception is raised
# on overflow, we temporarily set the appropriate error flags here and
# set them back when we are finished.
olderrflags = np.seterr(all='ignore')
try:
with np.errstate(all='ignore'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a pre-1.6 addition to numpy correct? (we are testing 1.6 with py2.7 on travis so this should be fine, but just being mildly paranoid)

Copy link
ContributorAuthor

@anntzeranntzerMay 29, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes.

$ git blame numpy/core/numeric.py | grep 'class errstate'cf3eb93b numpy/core/numeric.py (Travis Oliphant       2006-10-11 23:52:53 +0000 2929) class errstate(object):

# Check for collision
if self._linestyle in ['None', None]:
# If no line, return the nearby point(s)
Expand All@@ -480,20 +480,9 @@ def contains(self, mouseevent):
else:
# If line, return the nearby segment(s)
ind = segment_hits(mouseevent.x, mouseevent.y, xt, yt, pixels)
finally:
np.seterr(**olderrflags)

ind += self.ind_offset

# Debugging message
if False and self._label != '':
print("Checking line", self._label,
"at", mouseevent.x, mouseevent.y)
print('xt', xt)
print('yt', yt)
#print 'dx,dy', (xt-mouseevent.x)**2., (yt-mouseevent.y)**2.
print('ind', ind)

# Return the point(s) within radius
return len(ind) > 0, dict(ind=ind)

Expand DownExpand Up@@ -691,7 +680,8 @@ def recache(self, always=False):
interpolation_steps = self._path._interpolation_steps
else:
interpolation_steps = 1
self._path = Path(self._xy, None, interpolation_steps)
xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy.T)
self._path = Path(np.asarray(xy).T, None, interpolation_steps)
self._transformed_path = None
self._invalidx = False
self._invalidy = False
Expand DownExpand Up@@ -764,8 +754,6 @@ def draw(self, renderer):
tpath, affine = transf_path.get_transformed_path_and_affine()
if len(tpath.vertices):
self._lineFunc = getattr(self, funcname)
funcname = self.drawStyles.get(self._drawstyle, '_draw_lines')
drawFunc = getattr(self, funcname)
gc = renderer.new_gc()
self._set_gc_clip(gc)

Expand All@@ -788,7 +776,7 @@ def draw(self, renderer):
if self.get_sketch_params() is not None:
gc.set_sketch_params(*self.get_sketch_params())

drawFunc(renderer, gc, tpath, affine.frozen())
self._draw_lines(renderer, gc, tpath, affine.frozen())
gc.restore()

if self._marker and self._markersize > 0:
Expand DownExpand Up@@ -1234,27 +1222,6 @@ def set_dashes(self, seq):
def _draw_lines(self, renderer, gc, path, trans):
self._lineFunc(renderer, gc, path, trans)

def _draw_steps_pre(self, renderer, gc, path, trans):
steps = np.vstack(pts_to_prestep(*self._xy.T)).T

path = Path(steps)
path = path.transformed(self.get_transform())
self._lineFunc(renderer, gc, path, IdentityTransform())

def _draw_steps_post(self, renderer, gc, path, trans):
steps = np.vstack(pts_to_poststep(*self._xy.T)).T

path = Path(steps)
path = path.transformed(self.get_transform())
self._lineFunc(renderer, gc, path, IdentityTransform())

def _draw_steps_mid(self, renderer, gc, path, trans):
steps = np.vstack(pts_to_midstep(*self._xy.T)).T

path = Path(steps)
path = path.transformed(self.get_transform())
self._lineFunc(renderer, gc, path, IdentityTransform())

def _draw_solid(self, renderer, gc, path, trans):
gc.set_linestyle('solid')
renderer.draw_path(gc, path, trans)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp