Page 1 of 1

[GetDist] Legend for roots that aren't on all plots

Posted: May 13 2021
by Luke Hart
I have a situation where I'm making a triangle plot where the roots (let's say x1,x2,x3,x4) are plotted but then they have a hierarchy of added parameters (i.e. x1 has p1, x2 has p1 and p2 varying, x3 has p1,p2 and p3 varying...)

GetDist ignores the first root because obviously you cannot see p1 vs. p2 covariance (since the root x1 doesn't have p1 varying). How do you adjust the legend so it shows all the roots and not just the last 3??

Re: [GetDist] Legend for roots that aren't on all plots

Posted: May 13 2021
by Antony Lewis
Try starting with the root that has the most varying parameters.

Re: [GetDist] Legend for roots that aren't on all plots

Posted: May 14 2021
by Luke Hart
I already do, otherwise GetDist just doesn't work. It doesn't plot p2 or p1 unless the chains with p3,p2,p1 are all included first. But because p1 is only shown on the 1D distributions, it just won't show a label for the first parameter (The legend handles are clearly patches off the area of the contours rather than lines like standard matplotlib)

Re: [GetDist] Legend for roots that aren't on all plots

Posted: May 14 2021
by Luke Hart
I tried putting in a legend by hand (using ax and handles) but when I targeted the 1D plot for handles, it just didn't print a legend. I'm assuming the top of the triplot is the triangleObject.subplots[0][0] ?

Re: [GetDist] Legend for roots that aren't on all plots

Posted: May 14 2021
by Luke Hart
Update:

Fixed it, you can target the figure in the GetDistPlotter object and do the following (if anyone is interested):

Code: Select all

gPlotObj.fig.legend(gPlotObj.subplots[0][0].lines,lineLabels)
It's a bit more hardwired and it targets the lines as handles instead of Rectangle patches, but it looks good :)

Re: [GetDist] Legend for roots that aren't on all plots

Posted: May 14 2021
by Antony Lewis
I'm not sure there's a built-in solution for that, you may need to add the legend manually.