I have calculated two GP regression models and would like to have them plotted in the same figure.
Model 1
kernel = GPy.kern.RBF(input_dim=1, variance=.1, lengthscale=1.)
m1 = GPy.models.GPRegression(xa, ya,kernel)
m1.optimize_restarts(num_restarts = 10)
m1.optimize(messages=True)
from IPython.display import display
display(m1)
fig1 = m1.plot(plot_density=True)
m1.plot(plot_density=True)
GPy.plotting.show(fig2, filename='2')
Model 2
m2 = GPy.models.GPRegression(xe, ye,kernel)
m2.optimize_restarts(num_restarts = 10)
m2.optimize(messages=True)
from IPython.display import display
display(m2)
fig2 = m2.plot(plot_density=True,)
GPy.plotting.show(fig2, filename='2')
I want both plots in one figure, in either matplotlib or plotly i.e. GPy.plotting.show(fig, filename='filename')
.
Thanks
Using
matplotlib
, you can define a subplot, and specify the subplot to be used using the same axes (specifically, paramax
).I tested this out with a test data set:
Related: What is the best way of combining two independent plots with matplotlib?