If you just want to plot a simple regression, it will be easier to use seaborn.regplot
. This seems to work (although I'm not sure where the y axis minor grid goes)
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
x = 10 ** np.arange(1, 10)
y = x * 2
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, scatter_kws={"s": 100})
If you need to use lmplot
for other purposes, this is what comes to mind, but I'm not sure what's happening with the x axis ticks. If someone has ideas and it's a bug in seaborn, I'm happy to fix it:
grid = sns.lmplot('x', 'y', data, size=7, truncate=True, scatter_kws={"s": 100})
grid.set(xscale="log", yscale="log")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…