Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit the ticks in seaborn jointplot or joint grid?

Tags:

seaborn

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

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

like image 253
user3600497 Avatar asked Dec 03 '15 20:12

user3600497


People also ask

How do I reduce the number of ticks in Seaborn?

To decrease the density of x-ticks in Seaborn, we can use set_visible=False for odd positions.

What is the advantage of using Jointplot to plot data?

Draw a plot of two variables with bivariate and univariate graphs. This function provides a convenient interface to the JointGrid class, with several canned plot kinds. This is intended to be a fairly lightweight wrapper; if you need more flexibility, you should use JointGrid directly.

What is joint grid plot in Seaborn?

Grid for drawing a bivariate plot with marginal univariate plots. Many plots can be drawn by using the figure-level interface jointplot() . Use this class directly when you need more flexibility.


1 Answers

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

like image 144
Pablo Arnalte-Mur Avatar answered Sep 23 '22 19:09

Pablo Arnalte-Mur