Luk-StackOverflow
Luk-StackOverflow

Reputation: 361

python seaborn set xlim and ylim for jointplot and get rid of distribution information above and on right side

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

Answers (2)

AlexVI
AlexVI

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

ImportanceOfBeingErnest
ImportanceOfBeingErnest

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()

enter image description here

Upvotes: 1

Related Questions