Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
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.