How to flip data of the axes of a 2D function

My 2D function plot looks like

I want to exchange the data of the two axes and want the resulting function to look like the following plot


What should I do?
I am using the FEniCS 2019 version.

This is a matplotlib question, please ask it on the corresponding forum.