firedrake.pyplot package¶
Submodules¶
firedrake.pyplot.mpl module¶
- firedrake.pyplot.mpl.plot(function, *args, num_sample_points=10, complex_component='real', **kwargs)[source]¶
Plot a 1D Firedrake
Function- Parameters:
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
list of matplotlib
Line2D
- firedrake.pyplot.mpl.quiver(function, *, complex_component='real', **kwargs)[source]¶
Make a quiver plot of a 2D vector Firedrake
Function
- firedrake.pyplot.mpl.streamplot(function, resolution=None, min_length=None, max_time=None, start_width=0.5, end_width=1.5, tolerance=0.003, loc_tolerance=1e-10, seed=None, complex_component='real', **kwargs)[source]¶
Create a streamline plot of a vector field
Similar to matplotlib
streamplot- Parameters:
function – the Firedrake
Functionto plotresolution – minimum spacing between streamlines (defaults to domain size / 20)
min_length – minimum length of a streamline (defaults to 4x resolution)
max_time – maximum time to integrate a streamline
start_width – line width at beginning of streamline
end_width – line width at end of streamline, to convey direction
tolerance – dimensionless tolerance for adaptive ODE integration
loc_tolerance – point location tolerance for
at()
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.kwargs – same as for matplotlib
LineCollection
- firedrake.pyplot.mpl.tricontour(function, *args, complex_component='real', **kwargs)[source]¶
Create a contour plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the Firedrake
Functionto plotargs – same as for matplotlib
tricontourkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
ContourSetobject
- firedrake.pyplot.mpl.tricontourf(function, *args, complex_component='real', **kwargs)[source]¶
Create a filled contour plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the Firedrake
Functionto plotargs – same as for matplotlib
tricontourfkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
ContourSetobject
- firedrake.pyplot.mpl.tripcolor(function, *args, complex_component='real', **kwargs)[source]¶
Create a pseudo-color plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the function to plot
args – same as for matplotlib
tripcolorkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
PolyCollectionobject
- firedrake.pyplot.mpl.triplot(mesh, axes=None, interior_kw={}, boundary_kw={})[source]¶
Plot a mesh colouring marked facet segments
Typically boundary segments will be marked and coloured, but interior facets that are marked will also be coloured.
The interior and boundary keyword arguments can be any keyword argument for
LineCollectionand related types.- Parameters:
mesh – mesh to be plotted
axes – matplotlib
Axesobject on which to plot meshinterior_kw – keyword arguments to apply when plotting the mesh interior
boundary_kw – keyword arguments to apply when plotting the mesh boundary
- Returns:
list of matplotlib
Collectionobjects
- firedrake.pyplot.mpl.trisurf(function, *args, complex_component='real', **kwargs)[source]¶
Create a 3D surface plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the Firedrake
Functionto plotargs – same as for matplotlib
plot_trisurfkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
Poly3DCollectionobject
firedrake.pyplot.pgf module¶
pgfplot¶
pgfplots numbering by patch type:¶
2 2 3-------2 3---6---2
| \ | \ | | | |
| \ 5 4 | | 7 8 5
| \ | \ | | | |
0------1 0---3--1 0-------1 0---4---1
triangle triangle quadr rectangle biquadratic
FIAT/FInAT DoF orderings:¶
UFCTriangle:
2 2
| \ | \
| \ 4 3
| \ | \
0------1 0---5--1
DP1 DP2
UFCTetrahedron:
3. 3. 3
| \ | 4 \ edge 1-3
| .2. 7 .2. 5
|.~ \ |.8 6. \
0------1 0---9---1 1
DP1 DP2
UFCQuadrilateral:
1-------3 1---7---4
| | | |
| | 2 8 5
| | | |
0-------2 0---6---3
DQ1 DQ2
UFCHexahedron:
3-------7 3-------7 4--22--13 4--22--13
/. | / /| 7 . | 7 25 16 |
1 . | 1-------5 | 1 5 23 14 1--19--10 14
| . | | | | | 8 . | | |17 |
| 2 . . . 6 | | 6 2 3 .21 .12 2 20 11 12
|. / | |/ | 6 24 15 | |15
0-------4 0-------4 0--18---9 0--18---9
DQ1("equispaced") DQ2("equispaced")
- firedrake.pyplot.pgf.pgfplot(f, filename, degree=1, complex_component='real', print_latex_example=True)[source]¶
Produce a data file for LaTeX tikz plotting in parallel.
- Parameters:
f (Function) – Function to plot.
filename (str) – Name of the output file.
degree (int) – Degree of interpolation for plotting:
1(linear) or2(quadratic).complex_component (str) – Complex component to be plotted:
"real"or"imag".print_latex_example (bool) – Flag indicating whether to print a latex example or not.
Notes
Currently this functionality is only for plotting scalar functions in two- or three-dimensional spaces using 2D patches. If the topological dimension of the function is two, it outputs values on the cells, while, if the topological dimension is three, it outputs values on the exterior facets.
Do not use this for large functions, or it will take forever to compile your LaTeX file.
For large functions,
pdflatexmight fail to compile your document with the error message:TeX capacity exceeded, sorry [main memory size=5000000].If this happens, you could consider handling this error directly one way or another or consider usinglualatexinstead, which allocates memory dynamically.This function seamlessly works in parallel.
Module contents¶
- firedrake.pyplot.pgfplot(f, filename, degree=1, complex_component='real', print_latex_example=True)[source]¶
Produce a data file for LaTeX tikz plotting in parallel.
- Parameters:
f (Function) – Function to plot.
filename (str) – Name of the output file.
degree (int) – Degree of interpolation for plotting:
1(linear) or2(quadratic).complex_component (str) – Complex component to be plotted:
"real"or"imag".print_latex_example (bool) – Flag indicating whether to print a latex example or not.
Notes
Currently this functionality is only for plotting scalar functions in two- or three-dimensional spaces using 2D patches. If the topological dimension of the function is two, it outputs values on the cells, while, if the topological dimension is three, it outputs values on the exterior facets.
Do not use this for large functions, or it will take forever to compile your LaTeX file.
For large functions,
pdflatexmight fail to compile your document with the error message:TeX capacity exceeded, sorry [main memory size=5000000].If this happens, you could consider handling this error directly one way or another or consider usinglualatexinstead, which allocates memory dynamically.This function seamlessly works in parallel.
- firedrake.pyplot.plot(function, *args, num_sample_points=10, complex_component='real', **kwargs)[source]¶
Plot a 1D Firedrake
Function- Parameters:
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
list of matplotlib
Line2D
- firedrake.pyplot.quiver(function, *, complex_component='real', **kwargs)[source]¶
Make a quiver plot of a 2D vector Firedrake
Function
- firedrake.pyplot.streamplot(function, resolution=None, min_length=None, max_time=None, start_width=0.5, end_width=1.5, tolerance=0.003, loc_tolerance=1e-10, seed=None, complex_component='real', **kwargs)[source]¶
Create a streamline plot of a vector field
Similar to matplotlib
streamplot- Parameters:
function – the Firedrake
Functionto plotresolution – minimum spacing between streamlines (defaults to domain size / 20)
min_length – minimum length of a streamline (defaults to 4x resolution)
max_time – maximum time to integrate a streamline
start_width – line width at beginning of streamline
end_width – line width at end of streamline, to convey direction
tolerance – dimensionless tolerance for adaptive ODE integration
loc_tolerance – point location tolerance for
at()
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.kwargs – same as for matplotlib
LineCollection
- firedrake.pyplot.tricontour(function, *args, complex_component='real', **kwargs)[source]¶
Create a contour plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the Firedrake
Functionto plotargs – same as for matplotlib
tricontourkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
ContourSetobject
- firedrake.pyplot.tricontourf(function, *args, complex_component='real', **kwargs)[source]¶
Create a filled contour plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the Firedrake
Functionto plotargs – same as for matplotlib
tricontourfkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
ContourSetobject
- firedrake.pyplot.tripcolor(function, *args, complex_component='real', **kwargs)[source]¶
Create a pseudo-color plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the function to plot
args – same as for matplotlib
tripcolorkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
PolyCollectionobject
- firedrake.pyplot.triplot(mesh, axes=None, interior_kw={}, boundary_kw={})[source]¶
Plot a mesh colouring marked facet segments
Typically boundary segments will be marked and coloured, but interior facets that are marked will also be coloured.
The interior and boundary keyword arguments can be any keyword argument for
LineCollectionand related types.- Parameters:
mesh – mesh to be plotted
axes – matplotlib
Axesobject on which to plot meshinterior_kw – keyword arguments to apply when plotting the mesh interior
boundary_kw – keyword arguments to apply when plotting the mesh boundary
- Returns:
list of matplotlib
Collectionobjects
- firedrake.pyplot.trisurf(function, *args, complex_component='real', **kwargs)[source]¶
Create a 3D surface plot of a 2D Firedrake
FunctionIf the input function is a vector field, the magnitude will be plotted.
- Parameters:
function – the Firedrake
Functionto plotargs – same as for matplotlib
plot_trisurfkwargs – same as for matplotlib
- Keyword Arguments:
complex_component – If plotting complex data, which component? (
'real'or'imag'). Default is'real'.- Returns:
matplotlib
Poly3DCollectionobject
