Saturday 2 January 2021

Want to reproduce the same logical reasoning about overlapping contours on a triplot joint distribution

I have the following figure whose I want to apply the same logical reasoning for plotting all the contour and content of different ellipses (identified by a color).

In this example, there are 4 matrices plotted instead in my case below, I have 5 matrices (see 5 legend) but it doesn't matter.

Here this plot :

Logical of overlapping to reproduce

You will see that for each color, we have a light and dark shaders : this correspond to the 1 confidence level (1 C.L = dark shader) and 2 C.L (light shaders).

I am talking, for my issue, about the off-diagonal boxes. The yellow is the smallest area, meaning that we have the best constraints (each color in legend correspond to a covariance matrix).

Now, I would like to reproduce the way with which the overlapping is done. Here a first attempt from my script (with 5 matrices but we don't care, it is just an additional color and 2 more contours, dark and light).

my last triplot

As you can see, this is not very pretty and explicit (we can even say that's a mess to distinguish the contours as a function of increasing Figure of Merit (value of FoM in legend).

I have set the following snippet code to handle with these priorities between ellipses of different colors (FoM is inversely proportional from the area of ellipse):

Below the part to modify to have a correct and smart overlapping :

for tick in g.fig.axes[0].xaxis.get_major_ticks():
  tick.tick1line.zorder = 5

# Ordering applied here : try to be coherent in the overlapping
# by putting over all the smallest (yellow, 1 C.L) and ends by lowest 
# FoM, here, blue light (2 C.L) 
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, [0.1, 0.3, 0.5, 0.7, 2, 0.2, 0.4, 0.6, 0.8, 2]):
      c.zorder = z

The script alone is available directly on : script to modify

For off-diagonal boxes, I don't want to reproduce exactly the same figure than at the beginning (since data are not the same) but I am looking to reproduce the same overlapping logic and the effects of transparency on the first figure).

You can find the entire archive with the script here : script to fix for overlapping

especially the code snippet that set this ordering or priority betweeen contours is given above with the assignment c.zorder = z.

I have had posted the same kind of question but only for 2 matrices : old post with only 2 matrices to plot, i.e 2x2 = 4 contours ellipse. Here, I have at total 5x2 = 10 contours if I have into account the 1 C.L and 2 C.L ellipses for each color.

I hope that I have been clear, don't hesitate to ask me for further information, I would be glad to give you more details if necessary.

Any help/suggestion/clue is welcome.

ps: the python library that produces this "triplot" ("tri" like "triangular") is getdist.

the main routine is :

# Call triplot
g.triangle_plot([matrix1, matrix2, matrix3, matrix4, matrix5],
                names,
                filled = True,
                legend_labels = [],
                contour_colors = ['darkblue','purple','red','orange','yellow'],
                line_args = [{'lw':2, 'color':'darkblue'},{'lw':2, 'color':'purple'},
{'lw':2, 'color':'red'},{'lw':2, 'color':'orange'}, {'lw':2, 'color':'yellow'}]
                )

EDIT 1: I think that I may add transparency between all the different contours ( 1 C.L and 2 C.L confidence levels) but I am afraid that it complicates yet more the things.

just a last remark : the smallest yellow contour has to be fully filled like in the first figure of example. But the c.order = z is set to bad values that implies incoherent results like this.

From your point of view, what is the ideal c.order ordering to apply and on which criterion : I think for example to set the largest xlim/ylim of the box to the biggest ellipse 2 C.L (light "dark blue" contours) and after push all the others contours as a function of their area up to the smallest one (the yellow).

By the way, here an example of transparency that I have seen on the web :

yellow over blue itself over red

That is, yellow over blue itself over red : this is what I want to reproduce on my triplot (considering a kind of similar ordering for overlap).

EDIT 2: I did a try without considering the code snippet which determines manually the priority in overlapping.

By remove this code snippet and plot again, I get this figure :

Hidden policy of overlapping but results better

It's a little bit better than my first figure (for example, yellow contour is fully filled like orange one). But I don't know exactly how the priority in overlapping has been done. I have to look at more in the sources of getdist library but this is going to be a difficult task.

If anyone could understand the policy by default of overlapping in getdist ...



from Want to reproduce the same logical reasoning about overlapping contours on a triplot joint distribution

No comments:

Post a Comment