Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Axisartist testing + bugfixes #7545

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 16 commits into from
Feb 9, 2018
Merged
Show file tree
Hide file tree
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
Make axisartist.clip_path pseudo-tests real.
The results seem to be acceptable.
  • Loading branch information
QuLogic committed Feb 6, 2018
commit bc1bfab12150feaad88f0944dc1cda977452f577
26 changes: 0 additions & 26 deletions lib/mpl_toolkits/axisartist/clip_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,29 +133,3 @@ def clip_line_to_rect(xline, yline, bbox):
if bbox.containsx(x)]

return list(zip(lx4, ly4)), [c_left, c_bottom, c_right, c_top]


if __name__ == "__main__":

import matplotlib.pyplot as plt

x = np.array([-3, -2, -1, 0., 1, 2, 3, 2, 1, 0, -1, -2, -3, 5])
#x = np.array([-3, -2, -1, 0., 1, 2, 3])
y = np.arange(len(x))
#x0 = 2

plt.plot(x, y, lw=1)

from matplotlib.transforms import Bbox
bb = Bbox.from_extents(-2, 3, 2, 12.5)
lxy, ticks = clip_line_to_rect(x, y, bb)
for xx, yy in lxy:
plt.plot(xx, yy, lw=1, color="g")

ccc = iter(["ro", "go", "rx", "bx"])
for ttt in ticks:
cc = next(ccc)
for (xx, yy), aa in ttt:
plt.plot([xx], [yy], cc)

#xlim(
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions lib/mpl_toolkits/tests/test_axisartist_clip_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.testing.decorators import image_comparison
from matplotlib.transforms import Bbox

from mpl_toolkits.axisartist.clip_path import clip_line_to_rect


@image_comparison(baseline_images=['clip_path'],
extensions=['png'], style='default')
def test_clip_path():
x = np.array([-3, -2, -1, 0., 1, 2, 3, 2, 1, 0, -1, -2, -3, 5])
y = np.arange(len(x))

fig, ax = plt.subplots()
ax.plot(x, y, lw=1)

bbox = Bbox.from_extents(-2, 3, 2, 12.5)
rect = plt.Rectangle(bbox.p0, bbox.width, bbox.height,
facecolor='none', edgecolor='k', ls='--')
ax.add_patch(rect)

clipped_lines, ticks = clip_line_to_rect(x, y, bbox)
for lx, ly in clipped_lines:
ax.plot(lx, ly, lw=1, color='C1')
for px, py in zip(lx, ly):
assert bbox.contains(px, py)

ccc = iter(['C3o', 'C2x', 'C3o', 'C2x'])
for ttt in ticks:
cc = six.next(ccc)
for (xx, yy), aa in ttt:
ax.plot([xx], [yy], cc)