My patchsets for gnuplot and other work in progress

This web page has the current version of patches I am working on for gnuplot, and some sample output from the patched CVS version. Here are some instructions on how to get the source code and apply these patches.
Download and patch source from the CVS tree
Demo collection rendered using SVG. Warning: These plots are a serious test of SVG support in your browser. Do not be surprised if it locks up.
Nov 2006
Nov 2007

Documentation

This copy of the manual was generated from the cvs version as of 6 Nov 2007.
Unlike previous versions, it contains figures.
gnuplot.pdf
LaTeX tutorial
tutorial.dvi tutorial.pdf
Demo files for cvs version (bleeding edge) in SVG format
Working copy of auto-generated demo files
Demo files for cvs version in PNG format
Sourceforge copy
Embedding gnuplot output in a MSWord document
Word is highly biased against correct import of non-Microsoft file formats, including PostScript. If you need to embed a high quality gnuplot plot in a Word document, I suggest you try the EMF driver. Here is a sample Word document with embedded plots.

Work in progress

"range-frame" plots, where the axis spans only the range of the actual data (uses new object type ellipse).
This is
patchset #2025481 on SourceForge.

Recent additions to the CVS version on SourceForge

Hyperlinks automatically embedded in SVG output
Demo output from gnuplot's svg driver after modification to bracket each plot ('curve', or in this case 'histogram category') in a separate element in the xlink name space:
  <a xlink:title="Some identifier">
  ... plot elements ...
  </a>
Note how the cursor changes to indicate the link attached to each plot element, and to the corresponding sample in the key box.

In order to make it obvious how this works,
I have manually supplemented the 'title=' attribute with 'href='.
The idea is that in a production environment there would be a
post-processing script to take care of this 
automatically by substituting an
appropriate URL for each plot title.

Demos from the current CVS tree on SourceForge

They are in CVS, but not yet finalized.
UTF-8 support for PostScript terminal
This is patch #1746352 from Thomas Henlich. I've been working to add support for the enhanced text mode. Below are links to *.ps files produced by the demo scripts utf8.dem (existing demo) and utf8_enhanced.dem (in the patchset). The support is not yet perfect, as you can see by comparing the output of utf8.dem from the png terminal using the same font. Notice that the *.ps version fails to render the Hebrew characters. This may be a problem with the external utility ttftopf1 rather than with the gnuplot code per se.
Transparency
set fill style {transparent} {solid|pattern} ...

Absolute placement/alignment of 2D and 3D plot boundaries
allows lining up multiplot components so that the edges match up exactly

Extra information like color and and size can be read from a data file to modify individual data points
Here is a neat plot that uses the "with labels" style to place city names at their geographic coordinates, with the population indicated by font size.
Click for full-size image

Some lesser-known features in version 4.2

Animated gifs

Here are two animated gifs, produced using gnuplot's gif terminal type. This requires libgd version 2.0.29 or newer (2.0.33 is recommended).

Use of 3D impulses to display heat maps

This technique works well when you have individual values for many x/y data points rather than a smooth surface.

New 2D style 'plot with labels'

The first example is a projection of a peptide antibiotic molecule, with the C-alpha atom of each amino acid labeled by residue type. The 2D plot is not so useful in this case, but the 3D version (splot) with mouse enabled turns gnuplot into a quick molecular viewer! The command used to plot was
    plot 'labelplot.pdb' using 7:9 with lines notitle ,\
         '' using 7:9:4 with labels tc lt 3 font "arial,10" notitle
The records in labelplot.pdb look like this
ATOM      2  CA  GLY A   2      15.650   4.729 -25.837  1.00100.53           C  
ATOM      6  CA  GLY A   3      19.008   6.213 -26.458  1.00 97.90           C  
ATOM     10  CA  ARG A   4      19.415   8.236 -23.277  1.00 88.77           C  
ATOM     21  CA  GLU A   5      18.790   7.506 -19.627  1.00 63.87           C  
ATOM     30  CA  GLY A   6      16.256   9.024 -17.278  1.00 45.64           C  
ATOM     34  CA  VAL A   7      16.714   5.511 -15.945  1.00 39.94           C  
ATOM     41  CA  LEU A   8      20.247   6.236 -14.817  1.00 36.86           C  
ATOM     49  CA  LYS A   9      19.079   9.370 -13.209  1.00 29.25           C  
ATOM     58  CA  LYS A  10      16.415   7.489 -11.262  1.00 24.12           C  
and so on ...

New 3D style 'splot with labels'

This is a 3D star chart of bright stars near Earth. If displayed using a mouse-capable terminal type like X11 you can rotate the view interactively.
set pm3d
set border 0
set cbrange [0:100]
set view 42,100, 1.3
set colorbox horiz user origin .1,.1 size .8,.04
#
# set palette color rgbformula -33,-13,-10
#
set title "Gliese star catalog - 7 parsec neighborhood centered on Earth"
set cblabel "Luminosity" 0,1
#
splot 'nearmap.csv' using 5:6:7:11 with points pt 6 ps 2 pal notitle, \
      ''            using 5:6:7:11 with points pt 7 ps 1 pal notitle, \
      '' using 5:6:7:2 with labels font "arial,7" left point pt 0 offset 4,0 notitle
#

Mixed Histograms and Line Plots

In Nov 2001 Hans Olav Eggestad submitted a patch against gnuplot 3.7.1 that supported "categoric plots" and a method of reading text labels from a data file. This patch had a lot of attractive features, but so far as I know was never reworked to apply against the current CVS version of gnuplot. My 2nd string-handling patch allows something similar, however. Shown here is an approximate equivalent to one of Hans' demo plots generated with string patch #2 applied to current CVS version. This figure can be generated via either of two different features. The first way is to use the "plot with labels" command as a separate plot segment to place labels at a constant y value below the x axis.
  plot 'ctg-y2.dat' using 0:(-5):1 with labels
The second option is to specify a column of tic labels along with one of the plot segments
  plot 'ctg-y2.dat' using ($0):2:xtic(1) with ...
The data file being used is ctg-y2.dat. Hans Eggestad's original of of this figure is here.

Stacked Histograms

Another feature of Hans' patch was auto-generation of stacked-histograms. I haven't yet addressed the auto-generation part, but I have added a stacked-histogram plotting mode. The figure at right is an approximation of Hans' example ctg-vfd-stack2.

Histogramming Tabular Data

Here I show how the different histogram plotting options can be used to plot tabular data from a file. The data file being plotted is shown below. Notice that the first row contains column labels and the first column contains row labels. Both the row and column labels can be processed automatically by the histogram plotting code.
# US IMMIGRATION BY REGION AND SELECTED COUNTRY OF LAST RESIDENCE
#
Region   	Austria	Hungary	Belgium	Czechoslovakia	Denmark	France	Germany	Greece	Ireland	Italy	Netherlands	Norway	Sweden	Poland	Portugal	Romania	Soviet_Union	Spain	Switzerland	United_Kingdom	Yugoslavia	Other_Europe	TOTAL	
1891-1900	234081	181288	18167	-	50231	30770	505152	15979	388416	651893	26758	95015	226266	96720	27508	12750	505290	8731	31179	271538	-	282	3378014	
1901-1910	668209	808511	41635	-	65285	73379	341498	167519	339065	2045877	48262	190505	249534	-	69149	53008	1597306	27935	34922	525950	-	39945	7387494	
1911-1920	453649	442693	33746	3426	41983	61897	143945	184201	146181	1109524	43718	66395	95074	4813	89732	13311	921201	68611	23091	341408	1888	31400	4321887	
1921-1930	32868	30680	15846	102194	32430	49610	412202	51084	211234	455315	26948	68531	97249	227734	29994	67646	61742	28958	29676	339570	49064	42619	2463194	
1931-1940	3563	7861	4817	14393	2559	12623	144058	9119	10973	68028	7150	4740	3960	17026	3329	3871	1370	3258	5512	31572	5835	11949	377566	
1941-1950	24860	3469	12189	8347	5393	38809	226578	8973	19789	57661	14860	10100	10665	7571	7423	1076	571	2898	10547	139306	1576	8486	621147	
1951-1960	67106	36637	18575	918	10984	51121	477765	47608	43362	185491	52277	22935	21697	9985	19588	1039	671	7894	17675	202824	8225	16350	1325727	
1961-1970	20621	5401	9192	3273	9201	45237	190796	85969	32966	214111	30606	15484	17116	53539	76065	3531	2465	44659	18453	213822	20381	11604	1124492	

Plot selected data columns using clustered boxes
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
set xtic rotate by -45
set bmargin 5
plot 'immigration.dat' using 6:xtic(1) title col, \
   '' u 12 ti col, '' u 13 ti col, '' u 14 ti col


Plot each row as a stacked histogram
set key invert reverse Left outside
set key autotitle columnheader
set yrange [0:5e6]
set auto x
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75
#
plot 'immigration.dat' using 2:xtic(1) title 2, \
     for [i=3:22] '' using (column(i))


Group several stacked histograms into a single plot
set key under
set style histogram rows
set style fill solid border -1
set boxwidth 0.8
set xtics rotate by -45
plot \
newhistogram "Northern Europe", \
  'immigration.dat' using 6:xtic(1) t 6, \
  '' u 13 t 13, \
  '' u 14 t 14, \
newhistogram "Southern Europe", \
  '' u 9:xtic(1) t 9, \
  '' u 17 t 17, \
  '' u 22 t 22, \
newhistogram "British Isles", \
  '' u 10:xtic(1) t 10, \
  '' u 21 t 21


Does gnuplot suffer from bloat?

I made this chart to show the relative sizes of various gnuplot terminal drivers in the current CVS version (Nov 2007). To put the terminal sizes into perspective, you can compare them to the size of the full program. Note that selecting the full set of terminal types, including the wxWidgets terminal, almost doubles the size of the program compared to having no terminal types at all. Of course, building without support for any output devices would not be very useful:-)
      text    data     bss     dec     hex executable
    689394   39504   21504  750402   b7342 gnuplot (no terminals at all)
   1022593   72532   42400 1137525  115b75 gnuplot (default set of terminals)
   1179105   84500   51584 1315189  141175 gnuplot (default + wxwidgets)
     88223    4860   12552  105635   19ca3 gnuplot_x11 (auxilliary program) 
Here is a similar plot of the sizes of the gnuplot core components.


Ethan A Merritt
06 November 2007