Change to log scale while displacing the vertical scale of the marginal histogram on both axes in Seaborn jointplot

533 Views Asked by At

I am trying to draw jointplot with seaborn but I am not able to do the following:

  1. Change the scale to log-scale (similar to the way to do this in matplotlib ax.set_yscale('log')) on both axes of the marginal histograms.

  2. Display the vertical scale on both of the marginal histograms.

I attempted to do the following for point 2 above but it doesn't display vertical scale:

my_plot = sns.jointplot(x='x_axis', y='y_axis', data=my_df)
my_plot.fig.set_figwidth(19)
my_plot.fig.set_figheight(3)
for tick in my_plot.ax_marg_x.get_yticklabels():
    tick.set_visible(True)
plt.show()

enter image description here

For point 1, I don't really how to attempt it.

Thank you so much for your help in advance.

1

There are 1 best solutions below

0
On

An alternative option is to take the log (np.log10() or np.log()) of your y-column and plot that.

Example dataset

np.random.seed(seed=1)
ds = (np.arange(3)).tolist()*10
x = np.random.randint(100, size=(60)).tolist()
y = np.random.randint(low=1, high=100, size=(60)).tolist()
df = pd.DataFrame(data=zip(ds, x, y), columns=["ds", "x", "y"])

Jointplot on true y value

g = sns.jointplot(data=df, x="x", y="y")

enter image description here

Take log10 and jointplot it

df["log10y"] = np.log10(df["y"])
g = sns.jointplot(data=df, x="x", y="log10y")

enter image description here