I am currently trying to do a linear regression on a loglog plot using seaborn. Currently it tries to do the linear regression on the normal scale even though the data is shown plotted in loglog scale.
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pylab as plt
import seaborn as sns
x = np.arange(1, 10)
y = x**2.0
data = pd.DataFrame(data={'x': x, 'y': y})
f, ax = plt.subplots(figsize=(7, 7))
ax.set(xscale="log", yscale="log")
sns.regplot("x", "y", data, ax=ax)
The only work around that I have been able to do is to log x and y in advance of plotting but then the scale for the x and y are no longer nice compared to the code above.
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pylab as plt
import seaborn as sns
x = np.arange(1, 10)
y = x**2.0
data = pd.DataFrame(data={'x': x, 'y': y})
data=np.log(data)
f, ax = plt.subplots(figsize=(7, 7))
sns.regplot("x", "y", data)
Is there a way to keep the loglog scale from the first example of code but have the linear regression apply to the loglog scale and not to the normal scale?