Skip to content

Show labels of grouped pandas dataframe in one legend #198

Description

@zxdawn

Description

Proplot plots the legend for each label instead of listing labels on one legend.
As a result, several legends are stacked together.

Steps to reproduce

importproplotasplotdf=pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
'foo', 'bar', 'foo', 'foo'],
'B' : ['one', 'one', 'two', 'three',
'two', 'two', 'one', 'three'],
'C' : np.random.randn(8),
'D' : np.random.randn(8)})
fig, axs=plot.subplots()
df.groupby('A')['C'].plot(legend=True, ax=axs)

Expected behavior:
test_group_legend_matplotlib

Actual behavior:
test_group_legend

Equivalent steps in matplotlib

importmatplotlib.pyplotaspltdf=pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
'foo', 'bar', 'foo', 'foo'],
'B' : ['one', 'one', 'two', 'three',
'two', 'two', 'one', 'three'],
'C' : np.random.randn(8),
'D' : np.random.randn(8)})
df.groupby('A')['C'].plot(legend=True)
plt.show()

Proplot version

0.6.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions