has2k1 / plotnine

A Grammar of Graphics for Python
https://plotnine.org
MIT License
4.01k stars 217 forks source link

`geom_segment`'s `lineend` parameter has no effect #854

Closed 123-fake-st closed 2 months ago

123-fake-st commented 2 months ago

While working on a submission for the 2024 Plotnine Contest, I noticed that specifying lineend='round' in a geom_segment has no effect. It appears that geom_segment does not pass on the value of lineend.

import polars as pl
import plotnine as p9

plot_data = pl.DataFrame({
    'x': range(1, 6),
    'xend': range(2, 7),
    'y': range(1, 6),
    'z': range(1, 6)
})

plot = (
    p9.ggplot(plot_data, p9.aes(x='x', xend='xend', y='y', yend='y', color='z'))
    + p9.labs(caption='Color gradient testing')
    + p9.geom_segment(size=8, lineend='round', raster=True)
)
plot.show()

geom_segment

This appears similar to #727 and checking the code, I believe it can be fixed similarly to https://github.com/has2k1/plotnine/commit/18b748fab0c8b0c6e9ab28090982ecf2c054cefc by modifying geom_segment to include:

capstyle=params["lineend"],

Happy to fork, test, and submit a pull request but it will take me a little time to get around to it.