Matplotlib - Python- GetDist tool - Overlapping 2 triangle plots (triplots) by calling twice the plot function: issue of visible priority between both

后端 未结 1 1289
生来不讨喜
生来不讨喜 2021-01-13 14:58

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 covar

相关标签:
1条回答
  • 2021-01-13 15:15

    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:

    1. filled area for 2 sigma of 1st sample
    2. filled area for 1 sigma of 1st sample
    3. contour lines for 1st sample
    4. filled area for 2 sigma of 2nd sample
    5. filled area for 1 sigma of 2nd sample
    6. 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 in zip(ax.collections, [17,19,21,18,20,21]):
               c.zorder = z 
    

    0 讨论(0)
提交回复
热议问题