# 3D plot using native FEniCS

**URL:** <https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327>\
**Category:** Errors\
**Created:** [May 16, 2022, 8:27am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327 "2022-05-16T08:27:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![renol-kth](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Post date:** [May 16, 2022, 8:27am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/1 "2022-05-16T08:27:02Z")

</div>

I am trying to solve PDEs in 3D in fenics (not fenicsX).  
The following code

```auto
from dolfin import *
from mshr import *
import dolfin.common.plotting as fenicsplot
import numpy as np
from matplotlib import pyplot as plt

res = 8
mesh = UnitCubeMesh(res,res,res)
plot(mesh)

```

produces this Error message:

```auto
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-30-6bb53f29cf03> in <module>
      7 res = 8
      8 mesh = UnitCubeMesh(res,res,res)
----> 9 plot(mesh)

/usr/local/lib/python3.6/dist-packages/dolfin/common/plotting.py in plot(object, *args, **kwargs)
    436 # Plot
    437 if backend == "matplotlib":
--> 438 return _plot_matplotlib(object, mesh, kwargs)
    439 elif backend == "x3dom":
    440 return _plot_x3dom(object, kwargs)

/usr/local/lib/python3.6/dist-packages/dolfin/common/plotting.py in _plot_matplotlib(obj, mesh, kwargs)
    280 else:
    281 ax = plt.gca()
--> 282 ax.set_aspect('equal')
    283 
    284 title = kwargs.pop("title", None)

/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_base.py in set_aspect(self, aspect, adjustable, anchor, share)
   1279 if (not cbook._str_equal(aspect, 'auto')) and self.name == '3d':
   1280 raise NotImplementedError(
-> 1281 'It is not currently possible to manually set the aspect '
   1282 'on 3D axes')
   1283 

NotImplementedError: It is not currently possible to manually set the aspect on 3D axes

```

I know from other posts, that people suggest to use different Python libraries, like vedo or just use Paraview instead.

Is there really no way to create 3D plots with the native FEniCS installation or Matplotlib?  
How can this be the case, if FEniCS is the go-to PDE library? Isn’t solving 3D problems kind of a standard use case of such a library?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 16, 2022, 8:34am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/2 "2022-05-16T08:34:00Z")

</div>

This has been fixed in the later versions of fenics, see: [Error in opening 3D plots in fenics and .pvd files in Paraview 5.8.0 in Ubuntu 19.04 - #2 by dokken](https://fenicsproject.discourse.group/t/error-in-opening-3d-plots-in-fenics-and-pvd-files-in-paraview-5-8-0-in-ubuntu-19-04/2442/2)

---

<div class="post-metadata">

**Author:** ![renol-kth](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Post date:** [May 16, 2022, 11:04am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/3 "2022-05-16T11:04:34Z")

</div>

Thank you for your quick response!

Does the fact that I get this error message imply, that my FEniCS Docker image is outdated?  
If i remember correctly, I installed this image:  
[https://quay.io/repository/fenicsproject/stable?tab=tags&tag=latest](https://quay.io/repository/fenicsproject/stable?tab=tags&tag=latest)

…which was suggested here:  
[https://fenics.readthedocs.io/projects/containers/en/latest/introduction.html](https://fenics.readthedocs.io/projects/containers/en/latest/introduction.html)

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 16, 2022, 12:41pm UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/4 "2022-05-16T12:41:30Z")

</div>

Have you called `docker pull quay.Io…:latest` to make sure the image is up to date.

---

<div class="post-metadata">

**Author:** ![renol-kth](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Post date:** [May 16, 2022, 6:44pm UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/5 "2022-05-16T18:44:08Z")

</div>

I ran

```auto
docker pull quay.io/fenicsproject/stable:latest

```

and got

```auto
latest: Pulling from fenicsproject/stable
c64513b74145: Already exists
01b8b12bad90: Already exists
...
...
4eb92b6670f4: Already exists
Digest: sha256:ea64e15a739da61be9e440261f86f02930d678ff6eb800768347a87e4975759b
Status: Image is up to date for quay.io/fenicsproject/stable:latest
quay.io/fenicsproject/stable:latest

```

I stopped and restarted the container and I yielded the same error message as in my first post.  
What else could I have done wrong?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 16, 2022, 7:10pm UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/6 "2022-05-16T19:10:35Z")

</div>

Try using `dev:latest` instead of `stable:latest`

---

<div class="post-metadata">

**Author:** ![renol-kth](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Post date:** [May 17, 2022, 7:35am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/7 "2022-05-17T07:35:13Z")

</div>

I ran

```auto
docker pull quay.io/fenicsproject/dev:latest

```

and then

```auto
docker run --name notebook -w /home/fenics -v $(pwd):/home/fenics/shared -d -p 127.0.0.1:8889:8889 quay.io/fenicsproject/dev 'jupyter-notebook --ip=0.0.0.0'

```

(as suggested here [https://fenics.readthedocs.io/projects/containers/en/latest/jupyter.html](https://fenics.readthedocs.io/projects/containers/en/latest/jupyter.html)). In this last step I tried to use another port (127.0.0.1:8889:8889 ), as the one used for the stable installation (127.0.0.1:8888:8888) - i don’t know whether that was necessary.

When i start a container using FEniCS dev version, i still get the error from the first post.  
When i run

```auto
import dolfin as df
print (df. __version__ )

```

i get

```auto
2019.1.0

```

Is 2019… the latest version? Do I have to remove the stable installation first?  
Also: is it not possible to do 3D plots in the stable version? That would be very surprising to me.

---

<div class="post-metadata">

**Author:** ![renol-kth](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Post date:** [May 19, 2022, 9:39am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/8 "2022-05-19T09:39:40Z")

</div>

Is there no way to visualize 3D simulations in FEniCS? ☹

Or do you recommend exporting the data and using ParaView?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [May 19, 2022, 9:46am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/9 "2022-05-19T09:46:05Z")

</div>

The `dev:latest` should be 2019.2.0.dev. Please add:  
`:latest` at the end of your initialization of the docker container, i.e. something along the lines of

```auto
docker run --name notebook -w /home/fenics -v $(pwd):/home/fenics/shared -ti -p 8888:8888 quay.io/fenicsproject/dev:latest 'jupyter-notebook --ip=0.0.0.0' 

```

There are also several other modules that supports dolfin functions and meshes, such as vedo: [vedo.dolfin API documentation](https://vedo.embl.es/autodocs/content/vedo/dolfin.html#vedo.dolfin)  
and pyvista [Read FEniCS/Dolfin Meshes — PyVista 0.34.1 documentation](https://docs.pyvista.org/examples/00-load/read-dolfin.html?highlight=dolfin)

---

<div class="post-metadata">

**Author:** ![renol-kth](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@renol-kth](https://fenicsproject.discourse.group/u/renol-kth)\
**Post date:** [May 21, 2022, 9:09am UTC](https://fenicsproject.discourse.group/t/3d-plot-using-native-fenics/8327/10 "2022-05-21T09:09:30Z")

</div>

Many thanks, it worked!

Summary for everyone who faces the same problem in the future:

1. Following [LINK](https://fenics.readthedocs.io/projects/containers/en/latest/introduction.html) and the advice from @dokken I pulled the latest dev container:

```auto
docker pull quay.io/fenicsproject/dev:latest

```

1. Then one runs a docker container from this image using the following command (it is @dokken 's suggestion on changing the instructions from [LINK](https://fenics.readthedocs.io/projects/containers/en/latest/jupyter.html)):

```auto
docker run --name notebook-dev -w /home/fenics -v $(pwd):/home/fenics/shared -d -p 127.0.0.1:8888:8888 quay.io/fenicsproject/dev:latest 'jupyter-notebook --ip=0.0.0.0'

```

1. Then one can look at the list of all pulled containers to get the container ID by doing:

```auto
docker ps -a

```

1. Run the following command to get the link to the Jupyter Notebooks with the FEniCS environment:

```auto
docker logs <dockerID>

```
