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

capstyle/joinstyle support for matplotlib.collections.Collection #8277

Closed
Labels
Milestone
@blatts

Description

@blatts

Bug report

Bug summary

matplotlib.collections.LineCollection does not support modifying cap style and join style. I found a similar problem description on stack exchangehere, but no solution could be offered.

Code for reproduction

Any plot using collections.LineCollection, for instance a matplotlib.axes.Axes.errorbar plot. Here, the error bars are drawn using a LineCollection object and the ends of the error bars are square. It would be great if they could be changed to have round caps.

import numpy as npimport matplotlib.pyplot as pltxs = np.linspace(0, 1)ys = np.ones(xs.shape)dys = ys * 0.1fig = plt.figure()ax = fig.add_subplot(1, 1, 1)ax.errorbar(xs, ys, dys)fig.show()

Actual outcome

As expected, the LineCollection produces lines with the default cap and join styles of the renderer.

Expected outcome

This would be a new feature and has never worked with matplotlib. It would be easy to implement and performance could remain the same if the matplotlib.collections.Collection base class could be modified to support setting a default cap style and join style for the whole collection.

A simple fix would be to add "gc.set_capstyle(...)" and "gc.set_joinstyle(...)" to the Collection.draw method and add corresponding default values to the Collection object. Such a change would allow fixing the example above by adding a single line without modifying the errorbar-related code:

import numpy as npimport matplotlib.pyplot as pltxs = np.linspace(0, 1)ys = np.ones(xs.shape)dys = ys * 0.1fig = plt.figure()ax = fig.add_subplot(1, 1, 1)_, _, col = ax.errorbar(xs, ys, dys)\col.set_capstyle('round')fig.show()

Matplotlib version

Matplotlib 2.0.0 all platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp