Search code examples
pythonmatplotlibcontourfill

Python Getdist library : issue with shift between lines contours and filled contour


I am faced now to a new problem using GetDist library available on home page of GetDist. Examples are given in this getdist plot gallery.

This is a tool to plot joint distribution for a set of covariance matrices.

Everything works fine except one detail that disturbs me : If I zoom very deeply, I notice a slight shift between the contours filled and the lines contours. I illustrate this by the following zoomed figure (smallest contours refers to 1 sigma uncertainty and the largest 2 sigma) representing the ellipse of 2 covariance matrices.

illustration of not wanted space between filled area and lines contours

In this figure, I zoom very deeply on a subplot. Classically, if I unzoom the figure, I get this kind of image :

classical triplot

The relevant section that generates the triplot is :

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

I don't understand why filled area (red and darkblue) exceeds slightly the lines of the corresponding contours.

Maybe it is related to my conputation of limits of ellipse along x-coordinates and y-coordinates in order to fully fill the subplot and the rounding errors. I tried to modify these paramters without success.


Solution

  • I haven't looked in the code, but what I can see from the image is, that the border is half inset and half outset. I assume that the border has a transparency like the shape's fill color and thus it has the effect of a shifted dark border while this is just the part where the transparent border and the transparent background overlay.

    enter image description here

    The following example shows two circles, with a backgroundcolor rgba(0,0,0,0.5). The border on circle A has no opacity: rgb(0,0,0,1) while on circle B the border color matches the fill color (so 50% opacity: rgba(0,0,0,0.5).