Harald Thomson
Harald Thomson

Reputation: 784

Turn off x-axis marginal distribution axes on jointplot using seaborn package

There is a similar question here, however I fail to adapt the provided solutions to my case.

I want to have a jointplot with kind=hex while removing the marginal plot of the x-axis as it contains no information. In the linked question the suggestion is to use JointGrid directly, however Seaborn then seems to to be unable to draw the hexbin plot.

joint_kws = dict(gridsize=70)
g = sns.jointplot(data=all_data, x="Minute of Hour", y="Frequency", kind="hex", joint_kws=joint_kws)
plt.ylim([49.9, 50.1])
plt.xlim([0, 60])
g.ax_joint.axvline(x=30,ymin=49, ymax=51)
plt.show()
plt.close()

resulting figure

  1. How to remove the margin plot over the x-axis?
  2. Why is the vertical line not drawn?
  3. Also is there a way to exchange the right margin to a plot which more clearly resembles the density?

edit: Here is a sample of the dataset (33kB). Read it with pd.read_pickle("./data.pickle")

Upvotes: 4

Views: 1475

Answers (1)

tgrandje
tgrandje

Reputation: 2514

I've been fiddling with an analog problem (using a scatterplot instead of the hexbin). In the end, the solution to your first point is awkwardly simple. Just add this line :

g.ax_marg_x.remove()

Regarding your second point, I've no clue as to why no line is plotted. But a workaround seems to be to use vlines instead :

g.ax_joint.vlines(x=30, ymin=49, ymax=51)

Concerning your last point, I'm afraid I haven't understood it. If you mean increasing/reducing the margin between the subplots, you can use the space argument stated in the doc.

Upvotes: 3

Related Questions