Reputation: 361
Hello I am new to Python and to Seaborn. I would just like to set x-limits and y-limits to a Seaborn jointplot. Furthermore I would like to plot this figure without the distribution information above and at the right side of the main plot. How can I do that? I am trying something like this:
import numpy as np
import matplotlib.pyplot as plt from
matplotlib.ticker import NullFormatter
import seaborn as sns
sns.set(style="ticks")
xData = np.random.rand(100,1)*5
yData = np.random.rand(100,1)*10
xlim = [-15 15]
ylim = [-20 20]
g = sns.jointplot(xData, yData, kind="hex", color="b", xlim, ylim)
Upvotes: 5
Views: 10354
Reputation: 149
xlim
and ylim
should be tuples. hence your code should be:
import numpy as np
import matplotlib.pyplot as plt from
matplotlib.ticker import NullFormatter
import seaborn as sns
sns.set(style="ticks")
xData = np.random.rand(100,1)*5
yData = np.random.rand(100,1)*10
g = sns.jointplot(xData, yData, kind="hex", color="b", xlim = (-15,15), ylim = (-20,20))
Upvotes: 8
Reputation: 339052
The joint axes of a seaborn jointplot
of kind="hex"
is a matplotlib hexbin
plot. Hence you can just call plt.hexbin(xData, yData)
.
import numpy as np
import matplotlib.pyplot as plt
xData = np.random.rand(100,1)*5
yData = np.random.rand(100,1)*10
xlim = [-5, 10]
ylim = [-5, 15]
plt.hexbin(xData, yData, gridsize=10)
plt.xlim(xlim)
plt.ylim(ylim)
plt.show()
Upvotes: 1