matplotlib shape tuple syntax fails for tuple of tuples
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 254
- Avg merge
- 10h 35m
- Merged PRs (30d)
- 9
Description
from https://github.com/machow/plotnine-guide/pull/20, matplotlib provides a special tuple syntax for creating shapes. This includes a "tuple of tuples" syntax for drawing things. However, it seems like this fails due to pandas groupby not knowing how to sort the tuple of tuples (when other shapes are involved).
In the example below, removing house from the data works, but with it in, raises a pandas sort error (can't compare int with tuple):
# polygon: (num, 0, angle)
pentagon = (5, 0, 60)
# star: (num, 1, angle)
five_point_star = (5, 1, 60)
# astericks: (num, 2, angle)
five_point_astericks = (5, 2, 60)
# path: list[tuple(float, float)]
house = ((-2, -3), (-2, -1), (0, 0), (2, -1), (2, -3), (-2, -3))
shape = [pentagon, five_point_star, five_point_astericks, house]
shapes = pd.DataFrame(
{
"shape": shape,
"x": list(range(len(shape))),
"y": [0] * len(shape),
}
)
(
ggplot(shapes, aes("x", "y"))
+ geom_point(aes(shape="shape"), size=5)
# + geom_text(aes(label="shape"), nudge_x=0.15)
+ scale_shape_identity(guide=None)
+ theme_void()
+ expand_limits(x=4.1)
)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied example with the mixed shape values through geom_point and scale_shape_identity. Trace the pandas groupby step that sorts shape values and verify the tuple-of-tuples shape no longer causes an int-versus-tuple comparison error while the other shapes still render.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, pandas, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100