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 :
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).
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 between 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.
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 :
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 :
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.
I wish to understand the policy by default of overlapping in getdist.
EDIT 3: I realize that something interesting could solve my issue about ordering of overlapping and transparency like showed in the plot of EDIT 1 : For my figure that I want to get, the goal is to set overtop the yellow 1.CL and 2.CL, after, the orange 1 C.L and 2 C.L etc ... by order of priority.
The trick should be to keep contours for 1 C.L and 2 C.L for a given color, and let visible only the darline lines of these contours, without considering the color of below contours.
This way, I could distinguish all the lower contours of other colors.
If some lower contours are over all others, then the plain color will appear and no transparency will be applied since it is not overlapped.
Actually, in the 2 figures below (which illustrate my wanted rendering), I would like to have the same but with one changing, the 1 C.L plain yellow area with line contours and the 2 C.L light yellow with also contours lines , which are over all other contours.
For example, you can see on these 2 figures that yellow 1 C.L is not real plain yellow. Same issue for the 2 C.L yellow, it is not real light yellow.
Now, I have to :
look for how to set a contour for both 1 C.L and 2 C.L (and not just for 2 C.L confidence level)
apply transparency as respect of the contour lines of all other below contours and keep intact the plain yellow 1 C.L and light yellow 2 C.L. Caution, what I want is a transparency on lines of contours, not a transparency on the color itself.
It is a little tricky, I admit it, but I think this is possible (with getdist
, I have to search the necessary options or be able to find a way to achieve this ordering in overlapping without mixing all the transparency of each color.