# How to use gnuplot for Freefem on Windows

**URL:** <https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449>\
**Category:** General Discussion\
**Created:** [August 20, 2024, 10:43am UTC](https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449 "2024-08-20T10:43:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alice](https://community.freefem.org/u/Alice)\
**Post date:** [August 20, 2024, 10:43am UTC](https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449/1 "2024-08-20T10:43:06Z")

</div>

Hi All  
I am trying to plot on freefem by using gnuplot. I tried this example [Visualization](https://doc.freefem.org/examples/visualization.html#exampleplot). But the plot did not come from Gnuplot . I want to get this .Can anyone help?  
 ![Plot3](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/1/1d0e370b66e8bc8bb100652a0a84ff638455605d.png)

---

<div class="post-metadata">

**Author:** ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)\
**Post date:** [August 21, 2024, 9:24am UTC](https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449/2 "2024-08-21T09:24:59Z")

</div>

Hi Alice,  
Are you using a linux/UNIX system? The example works for me under ubuntu.  
The part of the script that calls gnuplot is

```auto
// Calls the gnuplot command, waits 5 seconds and generates a postscript plot (UNIX ONLY)
exec("echo 'plot \"plot.gp\" w l \n pause 5 \n set term postscript \n set output \"gnuplot.eps\" \n replot \n quit' | gnuplot");

```

---

<div class="post-metadata">

**Author:** ![Alice](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alice](https://community.freefem.org/u/Alice)\
**Post date:** [August 21, 2024, 10:14am UTC](https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449/3 "2024-08-21T10:14:09Z")

</div>

Hi Vincent,  
My computer is Windows, but I loaded gnuplot.

---

<div class="post-metadata">

**Author:** ![VaishnaviGnanam](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vaishnavignanam/32/2613_2.png) [@VaishnaviGnanam](https://community.freefem.org/u/VaishnaviGnanam)\
**Post date:** [August 22, 2024, 9:42am UTC](https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449/4 "2024-08-22T09:42:15Z")

</div>

Hi,  
It is simple. Use ofstream command in freefem code and download gnuplot then it is very much straightforward.

---

<div class="post-metadata">

**Author:** ![vlaude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/vlaude/32/939_2.png) [@vlaude](https://community.freefem.org/u/vlaude)\
**Post date:** [August 23, 2024, 12:19pm UTC](https://community.freefem.org/t/how-to-use-gnuplot-for-freefem-on-windows/3449/5 "2024-08-23T12:19:33Z")

</div>

I looked again into this problem, to have the script work under Windows11 similar to ubuntu/linux.  
I replaced the last line by:

```auto
exec("C:\\Progra~1\\gnuplot\\bin\\gnuplot.exe gnuplot.plt");

```

This is because gnuplot is installed under C:\Program Files\gnuplot\bin\ by the installer. Paths with a space character seem to not work well with Powershell (v1) when I execute FreeFem++ under Windows11, so it is here replaced with the 8-character old-Windows syntax.  
I also created the file gnuplot.plt to avoid trouble with the echo command:

```auto
plot "plot.gp" w l
pause 5
set term postscript
set output "gnuplot.eps"
replot
quit

```

Now it seems to work OK for me.  
Hope this helps,  
Vincent
