Python Issue of overlap as a function of the smallest areas of 1 Confidence level - priority for the smallest surface for each box

别等时光非礼了梦想. 提交于 2020-12-15 04:55:06

问题


In python3, I am faced to one issue 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 one call of the plotting function (triangle_plot). Specifying as first input the list of covariance matrix to plot is enough to have the (1 sigma,2 sigma) contours of each matrix. Here an example of triplot produced by 2 covariance matrixes (filled area correspond to 1 sigma confidence level (68%) and shaded to 2 sigma C.L (95%)). the color identifies each matrix (blue and red here) :

Everything works fine except one detail : I would like for each box that the smallest 1 C.L (Confidence Level) contour to be plot firstly, whatever it is the red or blue contour, but I want for the 1 C.L and for each box, that the smallest area to be drawn first (I don't remenber if I have to set a higher or lower zorder to perform this).

2) For the moment, I have applied the method given in the post solution given in a previous post, i.e with the code snippet :

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 

In my code, I have implemented this solution like this :

# Lower FoM 1 sigma disk before Higher FoM 2 sigma disk
for ax in g.fig.axes:
  geo = ax.get_geometry()
  if (geo[2]-1) // geo[0] > (geo[2]-1) % geo[0]:
    if (area2_1CL < area1_1CL):
      for c,z in zip(ax.collections, [0.6, 0.8, 2, 0.7, 0.9, 2]):
        c.zorder = z

The execution is good but with the loop for ax in g.fig.axes:, I don't know how to process each subplot (each box) to test the surface of blue 1 CL and red 1 CL.

3) I tried to test each amount of surface for each box with if (area2_1CL < area1_1CL): condition like this :

# Larger surface 1 sigma disk before smallest surface 2 sigma disk
for ax in g.fig.axes:
  geo = ax.get_geometry()
  if (geo[2]-1) // geo[0] > (geo[2]-1) % geo[0]:
    if (area2_1CL < area1_1CL):
      ax.collections.zorder = [0.6, 0.8, 2, 0.7, 0.9, 2]
    else:
      ax.collections.zorder = [0.7, 0.9, 2, 0.6, 0.8, 2]

But I get this error with this snippet code above :

Traceback (most recent call last):
  File "triplot_FLAT_NO_GAMMA_dev.py", line 281, in <module>
    ax.collections.zorder = [0.6, 0.8, 2, 0.7, 0.9, 2]
AttributeError: 'list' object has no attribute 'zorder'

I can compute in my code the parameter area1_CL1 and area2_CL1 (area = 1./np.sqrt(np.det(covariance_matrix[2:4,2:4])))

If someone sees how I could treat each box to test individually, for each of them, the comparison between the 2 1 C.L plain surfaces (the smallest contours on the plot, no the largest shaded ones), this would be kind to tell it, I don't see how to go further.

This way, we would see automatically the contour at 1 C.L in a box that has the smallest surface between 2 joint parameters since it would be drawn at first plane.

EDIT 1: a partial solution has been given on extract one interation with zip

来源:https://stackoverflow.com/questions/64861082/python-issue-of-overlap-as-a-function-of-the-smallest-areas-of-1-confidence-leve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!