question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

df.groupby(.).plot.scatter() creates a spurious initial plot

See original GitHub issue

Code Sample, a copy-pastable example if possible

df = pd.DataFrame([[1, 2], [3, 4], [5, 6], [7, 8]], columns=['x', 'y'])
df['cat'] = [1, 1, 1, 1]
df.groupby('cat').plot.scatter(x='x', y='y')

Problem description

The above creates 2 plots rather than one (notice there is only one category).

Tested in Jupyter 5.4.0 with %matplotlib inline.

Expected Output

A single plot.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None python: 3.5.3.final.0 python-bits: 64 OS: Linux OS-release: 4.9.0-6-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: it_IT.UTF-8 LOCALE: it_IT.UTF-8

pandas: 0.24.0.dev0+141.gf1ffc5fae pytest: 3.5.0 pip: 9.0.1 setuptools: 39.2.0 Cython: 0.25.2 numpy: 1.14.3 scipy: 0.19.0 pyarrow: None xarray: None IPython: 6.2.1 sphinx: 1.5.6 patsy: 0.5.0 dateutil: 2.7.3 pytz: 2018.4 blosc: None bottleneck: 1.2.0dev tables: 3.3.0 numexpr: 2.6.1 feather: 0.3.1 matplotlib: 2.2.2.post1153+gff6786446 openpyxl: 2.3.0 xlrd: 1.0.0 xlwt: 1.3.0 xlsxwriter: 0.9.6 lxml: 4.1.1 bs4: 4.5.3 html5lib: 0.999999999 sqlalchemy: 1.0.15 pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: 0.2.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
toobazcommented, Jul 18, 2018

I created #21963 to specifically refer to the creation of one plot per category, so that this issue is devoted to the spurious initial plot only (what @javadnoorb is fixing).

1reaction
WillAydcommented, Jul 16, 2018

@javadnoorb sounds reasonable. PRs are always welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas groupby scatter plot in a single plot - Stack Overflow
You can loop over groupby and create a scatter per group. That is efficient for less than ~10 categories. import pandas as pd...
Read more >
Pandas: How to Use Groupby and Plot (With Examples)
This tutorial explains how to create use groupby and plot with a pandas DataFrame, including examples.
Read more >
Compare the Best Data Viz Libraries for Python and Pandas
The purpose of this post is to help navigate the options for bar-plotting, line-plotting, scatter-plotting, and maybe pie-charting through an examination of ...
Read more >
Making Plots with Pandas groupby - In Plain English
A series of example code and plots using Pandas groupby method. ... how to use the DataFrame.groupby() method to make the plot I...
Read more >
scanpy plot
Scatter plot along observations or variables axes. obs ), variables ( . pl largely parallels the tl. umap () . f, Stage- and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found