How can I plot the transpose of a function?

Hi everyone,
I normally use ParaView for all my plotting, but I am currently creating some demos for my project and I want to produce plots as preliminary/quick results.

For a MWE I just present the first Poisson demo:

from dolfin import *
import matplotlib.pyplot as plt

mesh = UnitSquareMesh(32, 32)
(x, y) = SpatialCoordinate(mesh)

element = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
V = FunctionSpace(mesh, element)

u = Function(V)
v = TestFunction(V)

f = Constant(-6.0)
g = 1+ x**2 + 2*y**2
bc = DirichletBC(V, g, DomainBoundary())

F = inner(grad(u), grad(v))*dx - f*v*dx

solve(F == 0, u, bc)
c= plot(u)
plt.colorbar(c)
plt.show()

This produces the image
PoissonTest

Here u is naturally plotted on an (x,y) grid. Is there a way to plot it in a (x, 1-y) grid?

I know I can change the boundary conditions to do the exact same thing (and in ParaView). I was just wondering if there was a way to do it as post-processing in FEniCS.

I realise in this example it is way easier to edit the boundary conditions, but my real problem requires many sign changes that would make it unnecessarily confusing.

I looked at the documentation for plot , but I am not sure it contains an exhaustive list of all the options. The option “scale” scales the vector field in my example, so I wonder if there is a function “transpose” or similar.

Thank you!

old dolfin's plot function is intended for simple plots and uses matplotlib as the backend.

For custom plotting you should really use matplotlib to specify what you need. You can refer to dolfin.plot’s source to see how to do the basics.

Thank you for the response.

I want to use matplotlib, but the type of the output we get in FEniCS is what confuses me.
We have

type(u)
<class 'dolfin.function.function.Function'>
type(x)
<class 'ufl.geometry.SpatialCoordinate'>

I’m not sure how I can put it in matplotlib. Would I need to transform x and u into arrays (somehow) and then manipulate it that way? Or is there a way to do it keeping them as dolfin functions ?

It’s important to understand the difference between symbolic representation and an underlying numerical discretisation. I.e. ufl and dolfin.

As an example see how old dolfin plots rank 0 functions here.

Thank you! This helps a lot.