I am trying to plot my non-symmetric data using Seaborn's JointGrid. I can get it to use an equal aspect ratio, but then I have unwanted whitespace:
How do you remove the padding? The documentation for both jointplot and JointGrid simply say
size : numeric, optional
Size of the figure (it will be square).
I also tried going into feeding the extent
kwarg to both jointplot and JointGrid, as well as ylim
with no luck.
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
x = np.random.normal(0.0, 10.0, 1000)
y = np.random.normal(0.0, 1.0, 1000)
joint = sns.jointplot(x, y)
joint.plot_marginals(sns.distplot, kde=False)
joint.ax_joint.set_aspect('equal') # equal aspect ratio
plt.show()
For those who use Seaborn into a Jupyter Notebook, I suggest calling
set_figwidht()
andset_figheight()
just after thesns.jointplot()
command.Jupyter Example
You will need to set the
ylim
andxlim
parameters, which will limit the x and y axis to the tuple ranges you specify:e.g.
Stumbled upon this question looking for the answer myself. Having figured it out I thought I'd post the solution. As the
jointplot
code seems quite insistent on having the figure square I don't know if this is considered bad practice, but anyhow...If we look through the
jointplot
code and follow it intoJointGrid
, thesize
parameter tojointplot
(and equallyJointGrid
) is used in the following expression:So to get a non-square
JointGrid
plot, simply run:for a 6x4 figure.