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

Comments

@mdekstrand
Copy link

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

This comment has been minimized.

Copy link
Contributor

commented Jan 21, 2019

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Jan 21, 2019

@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

This comment has been minimized.

Copy link
Author

commented Jan 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.