Simplify colored_line() implementation in Multicolored lines example#29954
Simplify colored_line() implementation in Multicolored lines example#29954timhoffm merged 3 commits intomatplotlib:mainfrom
colored_line() implementation in Multicolored lines example#29954Conversation
39d5328 to
47e4a69
Compare
colored_line() implementation in Multicolored lines examplecolored_line() implementation in Multicolored lines example
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
| (xy[0, :][None, :], (xy[:-1, :] + xy[1:, :]) / 2, xy[-1, :][None, :]), axis=0 | ||
| ) | ||
| segments = np.stack((xy_mid[:-1, :], xy, xy_mid[1:, :]), axis=-2) | ||
| # Note that segments is [ |
There was a problem hiding this comment.
This comment is really confusing, and I don't think is correct, but certainly possible I am just confused. Segments should each be [0.5 * (xy[j-1] + xy[j]), xy[j], 0.5 * (xy[j] + xy[j+1])]?
There was a problem hiding this comment.
If something is "array" compatible, doesn't "np.asarray" convert it? I'm not clear on the motivation for this suggested change. I suppose it is a touch more efficient?
Since the following code still uses numpy methods, the only change here is for subclasses of ndarray, which |
|
I have noticed that making the starting point of each segment of the LineCollection more forward would make it plot more beautifully. I don't want to send any more PRs because there are seemingly endless improvements to this function, but I would be glad to have it as a consideration. |

PR summary
hstack,column_stack, etc.), which improves readability.autoscale_view, thusset_xlim, etc. need not to be called manually.stacklevel=2inwarnings.warn.PR checklist