Skip to content

labels of pandas dataframe in histogram plot #195

@kinyatoride

Description

@kinyatoride

Description

When pandas dataframe is passed to hist, the labels are shown in x axis. Can we put them to legend labels instead?

Steps to reproduce

import numpy as np
import pandas as pd
import proplot as plot

rng = np.random.default_rng()
x = rng.standard_normal((500, 2))
x = pd.DataFrame(x, columns=['a', 'b'])

fig, ax = plot.subplots()
ax.hist(x)

plot.show()

Expected behavior: [What you expected to happen]
Show actual x values, rather than showing labels in x axis.

Actual behavior: [What actually happened]
Screen Shot 2020-06-18 at 18 07 40

Equivalent steps in matplotlib

import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng()
x = rng.standard_normal((500, 2))
x = pd.DataFrame(x, columns=['a', 'b'])

fig, ax = plt.subplots()
ax.hist(x['a'], label='a')
ax.hist(x['b'], label='b')
ax.legend()
plt.show()

Screen Shot 2020-06-18 at 18 08 27

Proplot version

0.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions