Skip to content Skip to sidebar Skip to footer

Set Or Peg Bivariate Distribution Values Using Matplotlib

I've animated a bivariate gaussian distribution using matplotlib. I've calculated this distribution by adjusting the COV matrix to account for specific variables. I can provide gre

Solution 1:

I changed your normalization and gave explicit levels for contourf(), giving your desired result. The changes to your code are little; I replaced

normPDF = PDF - PDF.min()
    normPDF = normPDF / normPDF.max()

    cfs = ax.contourf(X, Y, normPDF, levels=10, cmap='viridis', alpha = 0.8)

with

normPDF = PDF * .5/max(PDF.max(), -PDF.min()) + .5cfs = ax.contourf(X, Y, normPDF, cmap='viridis', alpha = 0.8,
        levels=np.arange(0, 1, .1))

Here the result:enter image description here

Post a Comment for "Set Or Peg Bivariate Distribution Values Using Matplotlib"