Hybrid programming framwork for Java and Gnuplot.
Switch branches/tags
Nothing to show
Latest commit 444f266 Sep 30, 2017 @mleoking mleoking Update README.md
Failed to load latest commit information.
javagnuplothybrid Update examples.md Mar 28, 2016
LICENSE Updates: Mar 27, 2016
README.md Update README.md Sep 30, 2017



A hybrid programming framework for writing Gnuplot code in java.

The latest version of JavaGnuplotHybrid has been intergrated into LeoTask.

The JavaGnuplotHybrid folder is an eclipse project. You can download and import it into your eclipse workspace.

Download the demo | See the examples


Download the demo Double click the demo to run it. Here is the code of the demo.

Before running, make sure, you have Gnuplot installed and its path included in the system variable: PATH.

Windows system users can download, unzip, and install (install.bat) the all-in-one runtime package: LeoTaskRunEnv


JavaGnuplotHybrid is a light-weight library for plotting data in Java using Gnuplot.

This framework does not aim to implement a comprehensive sets of Java functions to cover all Gnuplot features. It rather promotes hybrid programming with Java and Gnuplot. The framework only does what Java is good at: data processing, functions, variables, etc..

It keeps its footprint in Gnuplot code to the minimum. So that, without this framework, you program code can be still reused in Gnuplot with ease. There is no vendor lock-in.

Thanks to this hybrid programming mode, the framework can support all features of the current and future versions of Gnuplot. There is no need to worry about whether this framework can keep up with the updating speed of Gnuplot. Because all necessary functions for the hybrid programming mode are done.


Here is the corresponding java code to produce a simple plot:

	public void plot2d() {
		JGnuplot jg = new JGnuplot();
		Plot plot = new Plot("") {
				xlabel = "x";
				ylabel = "y";
		double[] x = { 1, 2, 3, 4, 5 }, y1 = { 2, 4, 6, 8, 10 }, y2 = { 3, 6, 9, 12, 15 };
		DataTableSet dts = plot.addNewDataTableSet("2D Plot");
		dts.addNewDataTable("y=2x", x, y1);
		dts.addNewDataTable("y=3x", x, y2);
		jg.execute(plot, jg.plot2d);

It produces the following plot:

2D Plot

In addition a file named jgnuplot.xml is generated. It is the plot style file coded in Gnuplot script. You can modify the plot2d section in jgnuplot.xml to change the ploting styles. The framework uses tags warped in $$ in jgnuplot.xml to represent variables/methods/expressions in Java. Here is a simple plot2d section:

    set title "$info(1)$";
    plot for [i=1:$size(1)$] '-' title info2(1,i) w lp ls ls(i);

Here, $style2d$ and $header$ refers to the style2d and header sections in the jgnuplot.xml. $info(1)$ calls the built-in function of public String info(String dataTableSetNum) in JGnuplot.java with the parameter of "1" to output the "2D Plot" text in the previous example java code. $data(1,2d)$ calls the build-in method public String data(String dataTableSetNum, String type) in JGnuplot.java to output the data of the plot in 2d format.

Click here for more examples


  • Hybrid programming with Java and Gnuplot
  • Very light weight (just three core Classes)
  • Use tags in Gnuplot code to execute functions or get fields' values in Java.
  • Support both synchronized and asynchronized running of Gnuplot in Java. (synchronized: your java program will wait until you close the popped Gnuplot window; asynchronized: you java program will not wait.)
  • Capture error/normal text output of Gnuplot to the java terminal
  • Read Gnuplot code from xml files
  • Support Gnuplot code template.
  • More attractive plot styles

Example Figures:

2d 3d