The Looseleaf Papers

The best gnuplot script extension

Created

Modified

Published

Gnuplot script file extensions are not standard, as several people have observed.

Is there a standard file extension for gnuplot files?

I have seen .gnu, .plt, and .gplot as file extensions for gnuplot scripts.

I know Linux doesn’t care about file extensions, but what extension most universally declares to human beings “I am a gnuplot script!”?

— Phillip, “Is there a standard file extension for gnuplot files?”, March 31, 2011

http://stackoverflow.com/questions/5497889/is-there-a-standard-file-extension-for-gnuplot-files

There is no application/x-gnuplot in my copy of /etc/mime.types. Vim’s gnuplot.vim notes these possbilities:

" Filenames:        *.gnu *.plt *.gpi *.gih *.gp *.gnuplot scripts: #!*gnuplot

Here is the full list of options I have seen (in alphabetical order):

  • dem
  • gih
  • gnu
  • gnuplot
  • gp
  • gpi
  • gpl
  • gplt
  • plt

Let’s examine the case for and against each possibility.

.gih

Supposed to be used for Gnuplot help files, such as /usr/share/gnuplot/gnuplot.gih.

http://www.ccl.net/cca/software/SOURCES/C/gnuplot/gpt35doc/gnuplot.gih

Extension conflicts with GIMP’s brush files (Image Hose File).

89 hits on Google, mostly not Gnuplot scripts.

https://encrypted.google.com/search?q=filetype:gih

.gp

Seems like a logical choice for gnuplot files. Used in the official packaged versions of gnuplot as well as LaTeX packages.

Conflicts with Geode parameter files for Geoworks Glue; admittedly this is obscure.

http://dotwhat.net/gp/3562

178 hits in Google, a lot of them not scripts.

https://encrypted.google.com/search?hl=en&q=filetype%3Agp

.gnu

Kind of confusing, since gnuplot has nothing to do with the GNU project, but used in the official gnuplot demos, and probably the best of the 3-letter extension options.

Examples of gnuplot files with this extension:

The extension GNU does conflict with e.g. changelog:

135 hits on Google.

https://encrypted.google.com/search?q=filetype%3Agnu

.dem

The Windows installer for Gnuplot associates the file extensions .plt, .gp, and .gpl. It also offers .dem, short for “demonstration”.

168 hits on Google, mostly not Gnuplot files.

https://encrypted.google.com/search?q=filetype%3Adem

Examples of gnuplot files with this extension:

Not gnuplot scripts:

Conclusion

If all you’re trying to do is identify a text file as a gnuplot script, the shebang line:

#! /usr/bin/env gnuplot

is pretty effective.

74 hits on Google.

https://encrypted.google.com/search?q=%22%2Fusr%2Fbin%2Fenv+gnuplot%22

My opinion? Use .gnuplot for Gnuplot scripts and also include the shebang line. This is cross-platform, does not conflict with other filetypes, and leaves no doubt about being a Gnuplot script.