我不知道如何让 Seaborn Joint 图中的轴标签不以绝对值(而不是偏移量)显示。我知道我可以在 matplotlib 中使用
做到这一点plt.ticklabel_format(useOffset=False)
但是我如何让它在这个例子中工作
import numpy as np
import pandas as pd
import seaborn as sns
sns.set(style="white")
# Generate a random correlated bivariate dataset
rs = np.random.RandomState(5)
mean = [0, 0]
cov = [(1, .5), (.5, 1)]
x1, x2 = rs.multivariate_normal(mean, cov, 500).T
x1 = pd.Series(x1, name="$X_1$")
x2 = pd.Series(x2, name="$X_2$")
# Show the joint distribution using kernel density estimation
g = sns.jointplot(x1, x2, kind="kde", size=7, space=0, xlim=(0.995, 1.005))
如有任何建议,我们将不胜感激。
感谢您的建议,@ImportanceofbeingErnest;但这仍然没有解决问题。这是该图的屏幕截图,我希望 x 轴在轴标签方面看起来像 y 轴。如果我增大 x 范围,偏移量就会消失,但对于我的数据集来说,这并不起作用。
最佳答案
我的建议是添加 import matplotlib.pyplot as plt
在脚本 和 plt.ticklabel_format(useOffset=False)
的开头在最后。
由于联合图创建了多个轴,plt.ticklabel_format(useOffset=False)
只会影响最后一个。
一个简单的解决方案是使用
plt.rcParams['axes.formatter.useoffset'] = False
就在导入之后。这将关闭整个脚本的偏移量使用。
关于python - Seaborn 联合图,绝对轴标签未偏移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42169962/