Skip to content
Advertisement

Plot a triangle contour/surface matplotlib python: tricontourf/meshgrid

Given the following image, where plt.Polygon was used to create the triangle and plt.contourf the contour, i would like to ‘cut’ off the regions marked in X so that i only get the contour inside the triangle. How would i do this?

I’ve tried placing NaN values in the mentioned regions but the edges are square and therefore requires a large meshgrid to generate a ‘clean’ cut between the unwanted and wanted regions. Rather is it more appropiate to use plt.tricontourf? If so how should one approach it?

enter image description here

Advertisement

Answer

Thanks @Zephyr for the tricontourf solution, Heres how i solved it without the use of tricontourf and simply a meshgrid

JavaScript

Contour Plot

Surface Plot

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement