Skip to content
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

ENH: Expose symlog scaling in plotting API #24867

Closed
mdekstrand opened this issue Jan 21, 2019 · 3 comments · Fixed by #24968
Closed

ENH: Expose symlog scaling in plotting API #24867

mdekstrand opened this issue Jan 21, 2019 · 3 comments · Fixed by #24968
Labels
Milestone

Comments

@mdekstrand
Copy link

mdekstrand commented Jan 21, 2019

The default log-scaled axes, activated by the logx, logy, and loglog methods to the Pandas plotting API, do the straightforward thing and take the log of 0 values. It then attempt to plot with these infinite logs, and makes the entire plot unusable without warning in the presence of 0s.

For example:

draws = pd.DataFrame({'freq': np.random.zipf(1.7, 1000) - 1})
draws['rank'] = (-draws['freq']).rank()
draws.plot(x='rank', y='freq', kind='scatter', loglog=True)

Matplotlib provides another scale, the symlog scale, that makes a small region near 0 linear to avoid these problems. For quick-and-dirty 'look at my data on a log axis' plotting, symlog is significantly more useful.

I can access it like this:

draws = pd.DataFrame({'freq': np.random.zipf(1.7, 1000) - 1})
draws['rank'] = (-draws['freq']).rank()
p = draws.plot(x='rank', y='freq', kind='scatter', loglog=True)
p.set_xscale('symlog')
p.set_yscale('symlog')
p

Either making the symlog scale the default log scale for plotting, or supporting a loglog='sym' option, would make it significantly easier to do quick data inspection with Pandas' convenience plotting.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jan 21, 2019 via email

@TomAugspurger TomAugspurger added the Visualization plotting label Jan 21, 2019
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Jan 21, 2019
@TomAugspurger
Copy link
Contributor

@mdekstrand can you edit your post to include a minimal example? http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports. That way it'll be obvious when this can be closed.

@mdekstrand
Copy link
Author

@TomAugspurger done!

@jreback jreback modified the milestones: Contributions Welcome, 0.25.0 Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants