Reputation: 57
I can't figure out how to get the axis labels in my Seaborn Joint plot to not display with absolute values (rather than with an offset). I know I can do this in matplotlib with
plt.ticklabel_format(useOffset=False)
But how do I get it to work with this example
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))
Any suggestions would be greatly appreaciated.
Thanks for your suggestion, @ImportanceofbeingErnest; however that still hasn't solved the problem. Here is a screenshot of the plot, I want the x-axis to look like the y-axis in terms of axis labelling. The offsets disappear if I make the x range larger, but for my dataset that doesn't really work.
Upvotes: 1
Views: 1339
Reputation: 339300
My suggestion would be to add import matplotlib.pyplot as plt
at the beginning of the script and plt.ticklabel_format(useOffset=False)
at the end.
Due to the jointplot creating several axes, plt.ticklabel_format(useOffset=False)
will only affect the last of them.
An easy solution is to use
plt.rcParams['axes.formatter.useoffset'] = False
just after the imports. This will turn the offset use off for the complete script.
Upvotes: 1