# Plotting field lines

**URL:** <https://root-forum.cern.ch/t/plotting-field-lines/42284>\
**Category:** Newbie\
**Tags:** graphics\
**Created:** [November 13, 2020, 9:02am UTC](https://root-forum.cern.ch/t/plotting-field-lines/42284 "2020-11-13T09:02:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsubhro](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dsubhro/32/24279_2.png) [@dsubhro](https://root-forum.cern.ch/u/dsubhro)\
**Post date:** [November 13, 2020, 9:02am UTC](https://root-forum.cern.ch/t/plotting-field-lines/42284/1 "2020-11-13T09:02:16Z")

</div>

_ROOT Version:_ 6.22  
_Platform:_ Ubuntu  
_Compiler:_ G++

* * *

Let’s say, I have a field equation E = E(x,y,z) as a vector form. How do I plot field lines in root. Because for TGraphs I can only put f(x,y,z) =0 graph for 3D visualisation.  
Thank you.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 13, 2020, 10:06am UTC](https://root-forum.cern.ch/t/plotting-field-lines/42284/2 "2020-11-13T10:06:18Z")

</div>

May be you are looking for [TGraph2D](https://root.cern/doc/master/classTGraph2D.html) class?

---

<div class="post-metadata">

**Author:** ![dsubhro](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dsubhro/32/24279_2.png) [@dsubhro](https://root-forum.cern.ch/u/dsubhro)\
**Post date:** [November 13, 2020, 2:18pm UTC](https://root-forum.cern.ch/t/plotting-field-lines/42284/3 "2020-11-13T14:18:18Z")

</div>

Yes sir, I am aware of it.  
But the problem is let’s say E = e^2/(x^2 + y^2+ z^2)  
I have 3 independent parameters along with one dependent parameter.  
How do I plot the field lines then by 3 dimensionally?

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [November 13, 2020, 2:47pm UTC](https://root-forum.cern.ch/t/plotting-field-lines/42284/4 "2020-11-13T14:47:24Z")

</div>

[Class TF2](https://root.cern/doc/master/classTF2.html) shows how it can be done in 2d space.  
Lines on TF2 drawings corresponds to same function value.  
But in 3D space it is much more complicated.  
You could try draw [TF3](https://root.cern/doc/master/classTHistPainter.html#HP27) objects
