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.

regplot and xscale('log') don't get along without xlim

See original GitHub issue

Hi, When running:

sns.regplot('r', 'in_final_rate', data, ci=None, x_ci=None, logistic=True)
plt.xscale('log')

I get a malformed x-axis. However, if I add xlim():

sns.regplot('r', 'in_final_rate', data, ci=None, x_ci=None, logistic=True)
plt.xlim(1e-4, 1e-1)
plt.xscale('log')

Then it looks fine.

See notebook in this gist, which also includes a data file.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
zherebetskyycommented, May 22, 2018

The log-plot usually looks better if

  • the borders are set starting from some value (say 1)
  • the values of arguments have to be positive

Something like this should work

import matplotlib.pyplot as plt 
import seaborn as sns
x_column = 'col1' 
y_column = 'col2'
fg = sns.FacetGrid(data=pdf_clean[(pdf_clean['col1']>1) & (pdf_clean['col2']>1)], hue='col3', size=5, aspect=1.41, palette='muted')
fg.map(plt.scatter, x_column, y_column, alpha=.8).add_legend()`
axes = fg.axes
axes[0,0].set_xlim(1,)
axes[0,0].set_ylim(1,)
fg.set(xscale="log", yscale="log")
0reactions
maahlcommented, Apr 17, 2018

Ah, sorry for the confusion! Thanks for the tips 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to scale the x and y axis equally by log in Seaborn?
It would seem your x and y limits aren't the same. That's why it doesn't look linear. Might have to do with 0...
Read more >
Control Axis Limits of Plot - Python Graph Gallery
Controlling x and y axis limits of a plot using matplotlib functions plt.xlim() and plt.ylim()
Read more >
How to change axes limits in Seaborn? - GeeksforGeeks
Seaborn is a Python data visualization library based on matplotlib. ... bottom: This parameter is the bottom xlim/ylim in data coordinates ...
Read more >
Python Seaborn Tutorial For Beginners - DataCamp
This Seaborn tutorial introduces you to the basics of statistical data visualization in Python, from Pandas DataFrames to plot styles.
Read more >
Chapter 4. Visualization with Matplotlib - O'Reilly
Matplotlib is a multiplatform data visualization library built on NumPy arrays, ... Though Matplotlib does not have a built-in convenience routine for this ......
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