Skip to content

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

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

Closed
blatts opened this issue Mar 12, 2017 · 2 comments
Closed

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

blatts opened this issue Mar 12, 2017 · 2 comments
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature topic: rcparams
Milestone

Comments

@blatts
Copy link

blatts commented Mar 12, 2017

Bug report

Bug summary

matplotlib.collections.LineCollection does not support modifying cap style and join style. I found a similar problem description on stack exchange here, 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 np
import matplotlib.pyplot as plt
xs = np.linspace(0, 1)
ys = np.ones(xs.shape)
dys = ys * 0.1
fig = 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 np
import matplotlib.pyplot as plt
xs = np.linspace(0, 1)
ys = np.ones(xs.shape)
dys = ys * 0.1
fig = 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.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Mar 12, 2017
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Sep 24, 2017
@pkmn99
Copy link

pkmn99 commented Oct 12, 2017

I was struggling with this issue, hope this can be resolved soon.
I have a figure plot using both the seaborn barplot and matplotlib. Seaborn gives rounded errorbar, but matplotlib could't do it.

@tacaswell tacaswell added the Good first issue Open a pull request against these issues if there are no active ones! label Oct 16, 2017
NelleV added a commit that referenced this issue Oct 26, 2017
Add capstyle and joinstyle attributes to Collection class (Issue #8277)
@anntzer
Copy link
Contributor

anntzer commented Sep 26, 2019

fixed by #9523

@anntzer anntzer closed this as completed Sep 26, 2019
@anntzer anntzer modified the milestones: needs sorting, v2.2.0 Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Open a pull request against these issues if there are no active ones! New feature topic: rcparams
Projects
None yet
Development

No branches or pull requests

5 participants