suggestion: set current ax to g.ax_joint at end of jointplot
See original GitHub issueTested with seaborn 0.11.1
jointplot
(or JointGrid in general) leaves ax_marg_y
as current axis. Some people try to use plt.xlim()
or similar and are changing the marginal subplot instead of the main one. It could be nice to automatically set plt.sca(g.ax_joint)
when finishing the jointplot.
Example code:
import matplotlib.pyplot as plt
import seaborn as sns
tips = sns.load_dataset('tips')
g = sns.jointplot(data=tips, x='total_bill', y='tip')
# plt.sca(g.ax_joint)
plt.axhline(tips['tip'].mean(), ls='--', c='r')
plt.axhspan(tips['tip'].quantile(.25), tips['tip'].quantile(.75), color='y', alpha=.3)
plt.show()
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
In jointplot when using seaborn, how to set another legend in ...
1.I want to plot a joint distribution figure in 'hex' style with Seaborn, and I want to add a regression fitting using another...
Read more >seaborn.jointplot — seaborn 0.12.1 documentation - PyData |
An object managing multiple subplots that correspond to joint and marginal axes for plotting a bivariate relationship or distribution. See also. JointGrid. Set...
Read more >Understanding the jointplot vs jointgrid and the seaborn ...
Learn about the seaborn JointGrid in this Python seaborn tutorial video. I begin by explaining what is the joint grid and how it...
Read more >Seaborn jointplot link x-axis to Matplotlib subplots
I think this is a case where setting up anycodings_jointplot the figure using matplotlib functions is anycodings_jointplot going to be better than working ......
Read more >Joint Plot - Ajay Tech
The third plot is placed on the right margin of the bivariate graph with the orientation set to vertical and it shows the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It probably would make sense to do the same for
ax_heatmap
ofsns.clustermap
. That way e.g.plt.xlabel('features')
would affect the main subplot instead of the colorbar.I think the easiest change would be to do it at the end of
jointplot
. People who are usingJointGrid
directly are probably less likely to get bitten by this. That said, callingplt.gca
at the end of theJointGrid
constructor is probably fine too; but I would worry about the unintended consequences of changing the direction of axis sharing so I’d be -1 on the second proposal.A simple case would be:
But yes, without an established API pattern for “which axis to draw the distribution on”, it’s harder to be generic in that function.