How to edit the ticks in jointplot or JointGrid

9.2k Views Asked by At

How can I change the tick placement in a seaborn jointplot or JointGrid?

I'm looking for something similar to matplotlib's plt.xticks.

1

There are 1 best solutions below

2
On

You can access the 'axes' of a JointGrid object using ax_joint (for the main plot) and ax_marg_x or ax_marg_y for the marginal distributions' plots. Then, you can use the full API for the matplotlib axes to manipulate the details of the plot, and in particular you can use the get_xticks/set_xticks to change the tick placement.

Here's a basic example of how to use this to change the xticks/yticks positions:

import numpy as np
import seaborn as sns

g = sns.jointplot(np.random.rand(100), np.random.rand(100))

g.ax_joint.set_xticks([0, 0.34, 0.88])
g.ax_joint.set_yticks([-0.1, 0.5, 1, 1.1])

This results in the following plot:

Example of a seaborn jointplot with modified ticks