Skip to content

[Feature Request] Plot T/F mask directly as ones and zeros #30292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
halolord01 opened this issue Dec 16, 2019 · 1 comment
Closed

[Feature Request] Plot T/F mask directly as ones and zeros #30292

halolord01 opened this issue Dec 16, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request Visualization plotting

Comments

@halolord01
Copy link

Code Sample, a copy-pastable example if possible

x = pd.Series([False,True,True,False])
x.plot()
# Error thrown!
# Running version 0.24.2

Problem description

It would be nice to be able to directly use .plot() on true / false masks. Matplotlib currently supports plotting true / false masks with the below code (using the same x variable as above):

plt.plot(x.index, x.values)

Expected Output

Would be great if the code in the "code sample" section outputted the same as the matplotlib equivalent of ( plt.plot(x.index, x.values) ), where True translates to 1, and False to zero, and plots against the index values of the series.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Windows
OS-release: 10
pandas: 0.24.2
numpy: 1.16.4
scipy: 1.2.2
pandas_gbq: None
pandas_datareader: None

@jschendel
Copy link
Member

jschendel commented Dec 17, 2019

This is a dupe of #23719 and has been fixed/enabled by #27665 where the include_bool kwarg was added. This will be part of the upcoming 1.0 release.

In [1]: import pandas as pd; pd.__version__
Out[1]: '0.26.0.dev0+1327.g37dfcc1ac'

In [2]: x = pd.Series([False,True,True,False])

In [3]: x.plot(include_bool=True)
Out[3]: <matplotlib.axes._subplots.AxesSubplot at 0x123212518>

image

@jschendel jschendel added Duplicate Report Duplicate issue or pull request Visualization plotting labels Dec 17, 2019
@jschendel jschendel added this to the No action milestone Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Visualization plotting
Projects
None yet
Development

No branches or pull requests

2 participants