Matplotlib - Python- Getdist Tool - Overlapping 2 Triangle Plots (triplots) By Calling Twice The Plot Function: Issue Of Visible Priority Between Both
In python3, I am faced to 2 issues using the tool GetDist tool to produce triplot of covariance matrix. 1) Currently, I can plot 2 covariance matrixes on the same figure by only on
Solution 1:
It's kind of hacky but you can change the zorder
for the contours afterwards. For this we take the lower triangular plots and set the zorder
properties of the path and line collections. They appear in the following order:
- filled area for 2 sigma of 1st sample
- filled area for 1 sigma of 1st sample
- contour lines for 1st sample
- filled area for 2 sigma of 2nd sample
- filled area for 1 sigma of 2nd sample
- contour lines for 2nd sample
Originally all filled areas have zorder
1
and all lines 2
. We set them as required to e.g. 17, 19, 21, 18, 20, 21
.
Example:
from getdist import plots, gaussian_mixtures
samples1, samples2 = gaussian_mixtures.randomTestMCSamples(ndim=4, nMCSamples=2)
g = plots.get_subplot_plotter()
g.triangle_plot([samples1, samples2], filled=True, legend_labels = ['Contour 1', 'Contour 2'])
for ax in g.fig.axes:
geo = ax.get_geometry()
if (geo[2]-1) // geo[0] > (geo[2]-1) % geo[0]:
for c,z inzip(ax.collections, [17,19,21,18,20,21]):
c.zorder = z
Post a Comment for "Matplotlib - Python- Getdist Tool - Overlapping 2 Triangle Plots (triplots) By Calling Twice The Plot Function: Issue Of Visible Priority Between Both"