This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Plot range in Fenics

+2 votes

Hi,

Is there any way I can fixed the plotting range when I use the plot function in Fenics?

Thanks,

asked Apr 8, 2015 by lee FEniCS User (1,170 points)

1 Answer

+2 votes

Hi, consider range_min, range_max arguments to the plot function.

from dolfin import * 
import numpy as np

fe = Expression('k*sin(k*x[0])', k=0)

mesh = UnitIntervalMesh(100)
V = FunctionSpace(mesh, 'CG', 1)
f = interpolate(fe, V)

for k in np.linspace(1, 2, 100):
    fe.k = k 
    f.vector()[:] = interpolate(fe, V).vector()
    plot(f, range_min=0., range_max=1.)
    # plot(f)

interactive()
answered Apr 8, 2015 by MiroK FEniCS Expert (80,920 points)

Thanks a lot, MiroK !
Realized that "range_min=0." works but not "range_min=0" (without the decimal).

...