matplotlibplotfigureinsets

Save a corner plot in matplotlib figure


I have a simple corner plot. Lets just imagine the example from their page (taken from here):

import corner
import numpy as np

ndim, nsamples = 2, 10000
np.random.seed(42)
samples = np.random.randn(ndim * nsamples).reshape([nsamples, ndim])
figure = corner.corner(samples)

Now I want to ask, can I save this full canvas(of 3 plots together) in a single matplotlib figure, so that I may be able to inset this plot in another bigger matplotlib plot.

Additionally I have another question, is there a way to put custom legend/title on corner plots ?


Solution

  • this is my first post on Stack Overflow, with less than 50 reputation I cannot post this as a comment, hope it is helpful to some extent.

    Using this line to save the figure of corner plots:

    corner.corner.savefig('cornerplot...')
    

    Perhaps this is adjustable and can be reloaded as matplotlib subplot objects. Though understanding the source code would certainly be best