- Gnuplot is a portable command-line driven graphing utility. This example will show how to setup gnuplot in the various platforms. Download the latest version of the installer from gnuplot site. Run the downloaded file and allow it to run as administrator if requested. On the setup window select the language and follow the instructions.
- Gnuplot is a portable command-line driven graphing utility for many platforms. To leverage the powful gnuplot to plot beautiful image in efficicent way in python, we port gnuplot to python. Let’s see an example at first: #!/usr/bin/env python3 #coding=utf8 from pygnuplot import gnuplot g = gnuplot.
There are 2 common methods to make a plot using ns-3 and gnuplot (http://www.gnuplot.info):
Download gnuplot for free. A portable, multi-platform, command-line driven graphing utility. A famous scientific plotting package, features include 2D and 3D plotting, a huge number of output formats, interactive input or script-driven options, and a large set of scripted examples.
- Create a gnuplot control file using ns-3’s Gnuplot class.
- Create a gnuplot data file using values generated by ns-3.
This section is about method 1, i.e. it is about how to make a plot using ns-3’s Gnuplot class. If you are interested in method 2, see the “A Real Example” subsection under the “Tracing” section in the ns-3Tutorial.
Creating Plots Using the Gnuplot Class¶
The following steps must be taken in order to create a plot using ns-3’s Gnuplot class:
- Modify your code so that is uses the Gnuplot class and its functions.
- Run your code so that it creates a gnuplot control file.
- Call gnuplot with the name of the gnuplot control file.
- View the graphics file that was produced in your favorite graphics viewer.
See the code from the example plots that are discussed below for details on step 1.
An Example Program that Uses the Gnuplot Class¶
An example program that uses ns-3’s Gnuplot class can be found here:
In order to run this example, do the following:
This should produce the following gnuplot control files:
In order to process these gnuplot control files, do the following:
This should produce the following graphics files:
You can view these graphics files in your favorite graphics viewer. If you have gimp installed on your machine, for example, you can do this:
An Example 2-Dimensional Plot¶
The following 2-Dimensional plot
Gnuplot Windows
was created using the following code from gnuplot-example.cc:
An Example 2-Dimensional Plot with Error Bars¶
The following 2-Dimensional plot with error bars in the x and y directions
was created using the following code from gnuplot-example.cc:
An Example 3-Dimensional Plot¶
The following 3-Dimensional plot
Gnuplot Tutorial
was created using the following code from gnuplot-example.cc:
October 6th, 2010 | 14 Comments
If we want to plot a single point, we can do this by creating a data file, containing only one line:
But there exist an easier method without any additional data file. In Fig. 1 three points with different symbols are plotted.
Gnuplot Download
Fig. 1 Plot of three single points (code to produce this figure)
To achieve this we just use the following command:
Gnuplot
We use the possibility to tell Gnuplot with the '-'
input to read from standard input. Here we tell Gnuplot to do this three times. After the plot command the data is entered. Every single data entry have to ended with the e
line.
In order to have different symbols for the points we set them before:
Gnuplotrc
Note: if we want to use the replot
command then the above code will not work probably. But the same can be achieved by using: