How can I change the tick placement in a seaborn jointplot or JointGrid?
I'm looking for something similar to matplotlib's plt.xticks
.
How can I change the tick placement in a seaborn jointplot or JointGrid?
I'm looking for something similar to matplotlib's plt.xticks
.
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:
© 2022 - 2024 — McMap. All rights reserved.
for tick in ax.ax_joint.get_xticklabels(): tick.set_rotation(30)
– Covenantee