# How to Plot Field Lines

**URL:** <https://community.freefem.org/t/how-to-plot-field-lines/1552>\
**Category:** General Discussion\
**Created:** [February 23, 2022, 4:07pm UTC](https://community.freefem.org/t/how-to-plot-field-lines/1552 "2022-02-23T16:07:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![willrey](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/willrey/32/891_2.png) [@willrey](https://community.freefem.org/u/willrey)\
**Post date:** [February 23, 2022, 4:07pm UTC](https://community.freefem.org/t/how-to-plot-field-lines/1552/1 "2022-02-23T16:07:44Z")

</div>

Hello,

I’m comfortable with using the plot function to visualise the potential over a field, but how can I plot the field lines (perpendicular to the equipotentials, so that I can take a closer look at the flux paths)?

For context, I’m working on an electrical capacitance tomography problem and so seeing these paths of the electric flux will allow me to better understand the capacitance between each electrode in my system.

Thank you very much,  
Will

---

<div class="post-metadata">

**Author:** ![SamuelJosephs](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/samueljosephs/32/1046_2.png) [@SamuelJosephs](https://community.freefem.org/u/SamuelJosephs)\
**Post date:** [March 8, 2022, 3:45pm UTC](https://community.freefem.org/t/how-to-plot-field-lines/1552/2 "2022-03-08T15:45:53Z")

</div>

Can’t you just take the negative gradient of the function and plot the vector field?

So say you have solved for you scalar fespace u, then the following code should plot the field lines on top of u.

```auto
xomp = -dx(u);
ycomp = -dy(u);
zcomp = -dz(u);
plot(u,[xcomp,ycomp,zcomp],wait = true, fill = true);

```

If your problem is 2d not 3d then it would be the almost the same:

```auto
xomp = -dx(u);
ycomp = -dy(u);
plot(u,[xcomp,ycomp],wait = true, fill = true);

```

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [March 11, 2022, 1:08pm UTC](https://community.freefem.org/t/how-to-plot-field-lines/1552/3 "2022-03-11T13:08:30Z")

</div>

Sorry no simple way, in FreeFem++, but may be in Paraview it is possible but I don’t know.
