Subplots and JointGrid
See original GitHub issueSay I create a figure that will hold multiple plots, one of which I want to be a JointGrid
f = plt.figure(figsize=(12,6))
gs = gridspec.GridSpec(4,1 , height_ratios=[1.5,1.5,1.5, 1.5])
subplots = list(gs)
first_axis = f.add_subplot(subplots[0])
I would like to create a JointGrid
plot on this axis. Is there any way to do that?
JointGrid does not seem to accept an ax
parameter, I guess because it creates several axes (multiple of them, presumably), i.e. this doesn’t work:
sns.JointGrid(xcol, ycol, df, size=12, ax=first_axis)
How can I use sns.JointGrid
with subplot?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:19 (2 by maintainers)
Top Results From Across the Web
How to plot multiple Seaborn Jointplot in Subplot
jointplot calls JointGrid method, which in turn creates a new figure object every time it is called. Therefore, the hack is to make...
Read more >seaborn.JointGrid — seaborn 0.12.1 documentation - PyData |
Set up the grid of subplots and store data internally for easy plotting. Parameters: data pandas.DataFrame , numpy.ndarray , mapping, or ...
Read more >Understanding the jointplot vs jointgrid and the seaborn ...
Learn about the seaborn JointGrid in this Python seaborn tutorial video. ... or for the individual subplots or with the JointGrid methods.
Read more >How to plot a non-square Seaborn jointplot or JointGrid ...
Steps. Set the figure size and adjust the padding between and around the subplots. Create x and y data points using numpy. Create...
Read more >JointGrid - Ajay Tech
Few of the functions defined in pyplot are used at this level such as figure(), subplot() in order to create figure and axes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
I wrote a small class in this Stackoverflow anser that would allow to transfer a plot from one of the figure type seaborn graphs to a position of a gridspec in a different matplotlib figure. There are some minor issues still, so such solution needs a bit tweaking, but is in principle usable.
The output might then look something like this:
I have implemented this!
sns.pairplot(iris, grid_kws={'subplot_spec':gs[1]})
also works.I also implemented it for JointGrid:
(similar results for
g = sns.jointplot(x="total_bill", y="tip", kind='kde',data=tips, size=5, ratio=2, subplot_spec=gs[1])
)The JointPlot/jointplot implementation was pretty straightforward, however, PairGrid/pairplot depends on a change to matplotlib that is in the master branch but has not yet been released. The implementation of plt.subplots() was recently moved to fig.subplots(). That change allowed me to implement this without a giant overhaul to seaborn, because it allowed me to call subplots and use the sharex and sharey optional arguments on a pre-existing figure. To do it with the current release, one would have to implement sharex and sharey themselves. Then we’d probably want to change it to this implementation once the mpl update occurs anyway so I feel like that would be a waste.
I’m new to contributing, so I don’t know what the standard protocol is for features that rely on not-yet-released dependencies. Please advise.