Skip to content
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

Fix auto-closing in PolyCollection #3239

Merged
merged 2 commits into from Jul 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/collections.py
Expand Up @@ -809,10 +809,10 @@ def set_verts(self, verts, closed=True):
for xy in verts:
if len(xy):
if np.ma.isMaskedArray(xy):
xy = np.ma.concatenate([xy, np.zeros((1, 2))])
xy = np.ma.concatenate([xy, xy[0:1]])
else:
xy = np.asarray(xy)
xy = np.concatenate([xy, np.zeros((1, 2))])
xy = np.concatenate([xy, xy[0:1]])
codes = np.empty(xy.shape[0], dtype=mpath.Path.code_type)
codes[:] = mpath.Path.LINETO
codes[0] = mpath.Path.MOVETO
Expand Down
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/matplotlib/tests/test_collections.py
Expand Up @@ -475,6 +475,44 @@ def test_EllipseCollection():
ax.autoscale_view()


@image_comparison(baseline_images=['polycollection_close'],
extensions=['png'], remove_text=True)
def test_polycollection_close():
from mpl_toolkits.mplot3d import Axes3D
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised that this isn't part of the mpl3d test, rather than the collection tests...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it should be part of the mplot3d tests because mplot3d is optional.

On Sat, Jul 12, 2014 at 5:45 PM, Phil Elson notifications@github.com
wrote:

In lib/matplotlib/tests/test_collections.py:

@@ -475,6 +475,44 @@ def test_EllipseCollection():
ax.autoscale_view()

+@image_comparison(baseline_images=['polycollection_close'],

  •              extensions=['png'], remove_text=True)
    
    +def test_polycollection_close():
  • from mpl_toolkits.mplot3d import Axes3D

I'm surprised that this isn't part of the mpl3d test, rather than the
collection tests...


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3239/files#r14855507.

Copy link
Member

Choose a reason for hiding this comment

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

Bump. Did this ever get done?

Copy link
Member

Choose a reason for hiding this comment

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

No


vertsQuad = [
[[0., 0.], [0., 1.], [1., 1.], [1., 0.]],
[[0., 1.], [2., 3.], [2., 2.], [1., 1.]],
[[2., 2.], [2., 3.], [4., 1.], [3., 1.]],
[[3., 0.], [3., 1.], [4., 1.], [4., 0.]]]

fig = plt.figure()
ax = Axes3D(fig)

colors = ['r', 'g', 'b', 'y', 'k']
zpos = list(range(5))

poly = mcollections.PolyCollection(
vertsQuad * len(zpos), linewidth=0.25)
poly.set_alpha(0.7)

## need to have a z-value for *each* polygon = element!
zs = []
cs = []
for z, c in zip(zpos, colors):
zs.extend([z] * len(vertsQuad))
cs.extend([c] * len(vertsQuad))

poly.set_color(cs)

ax.add_collection3d(poly, zs=zs, zdir='y')

## axis limit settings:
ax.set_xlim3d(0, 4)
ax.set_zlim3d(0, 3)
ax.set_ylim3d(0, 4)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)