GithubHelp home page GithubHelp logo

eplot's Introduction

eplot

eplot ("easy gnuplot") is a ruby script which allows to pipe data easily through gnuplot and create plots quickly, which can be saved in postscript, PDF, PNG or EMF files. Plotting of multiple files into a single diagram is supported.

One plot per diagram

The easiest way is to pipe the data through the program. Let's assume that you have a file called data.txt, the syntax would be:

cat data.txt | eplot

Which will give a result looking like this:

alt text

If the input data is available in a file (as opposed to being the output of another program), then you may as well give its name as an argument to eplot. This works with several data files, which will be opened in seperate windows:

eplot file1
eplot file1 file2 file3

Multiple plots in a single diagram

There are several ways to create multiple plots on a single diagramm:

-m: Several input files: Just give the name of the files on the command line together with the -m option
-M: A single file, the data for the different curves are in different columns: give the name of the file on the command line or pipe the data through standard in, and set the -M option
-S: A single file, the data for the different curves are in the same column, but the curves are separated by blank lines: give the name of the file on the command line or pipe the data through standard in, and set the -S option

Examples:

eplot -m 'Measured A' 'Measured B' 'Measured C' 'Simulated A' 'Simulated B' 'Simulated C'
eplot -M singlefile.dat

Which will give a result looking like this:

alt text

Customize the plot

A couple of options allow to change various settings:

-r intervals    (e.g. -r [5:10][0:100]) Change the range of the x and the y axis
-R aspect-ratio     (e.g. -R 0.8)   Change the aspect ratio of the plot
-s size-factor  (e.g. -s 1.5)   Change the size (resolution) of the plot
-l curve-type   (e.g. -l points)    Change the type of curve
-w line-width   (e.g. -w 2) Change the line width (default: 1)
-t title    (e.g. -t 'Error Rate@Recall@Precision') Change the title(s) of the curve(s) (separated by @)
-x x-options    (e.g. -x 'sigma')   Change options of the x-axis, e.g. the label but also other options.
-y y-options    (e.g. -y 'error rate')) Change options of the y-axis, e.g. the label but also other options.
-B pos,height   (e.g. -B 100,0.1)   Add a vertical bar at position pos with height height. Several bars may be added, separated by @

For example, creating a plot of three curves (three types of classification accuracy measures in this case) which are stored as three different columns in the file data.txt, with a custmozed x-axis label and customized plot titles as well as a manual setting of the x and y range, can be done with this command:

cat data.txt | eplot -M -x 'number of neighbors' -r [1:20][0:1] -t 'Accuracy@Precision@Recall'

Saving into external files

Various options allow to save a plot into diffrent formats. The filename cannot be specified, it is fixed to "foo.XXX", XXX being the extention of the respective file format:

-P Save into a PNG image (foo.png)
-p Save into a postscript image (foo.ps)
-a Save into a PDF image (foo.pdf)
-e Save into a EMF image (foo.emf)

Selecting rows

In some situations you might want to plot data from a file but ignore part of the file contents. If the file is organized in columns, i.e. you will plot it using the -M option to eplot, then the selection of a subset of the file's columns can be done using the ec tool (say "extract column"). Just add it as a filter between the data and the eplot command. For instance, if you want to plot columns 2 and 3 only:

cat data.txt | ec 2 3 | eplot -M

ec is also usefull if the columns in the original file are not separated by whitespace but by another character. The character separater used by ec can configured by adding it on the command line preceeded by a dash. The output character separater is always whitespace, as requested by eplot. If, for example, you have a file whose columns are seperated by a semicolon and you want to plot columns 5 and 3, use the command:

cat data.txt | ec -; 5 3 | eplot -M

Installation

No setup is necessary. Just download the script files (eplot and ec) and put them into a directory which is in the PATH of your shell. Just be sure that the ruby shell is available as /usr/bin/ruby, else create a link or change the first line of each script.

The standard configuration of the script only works with gnuplot 4.0 or newer, the reason being a couple of changes in the gnuplot syntax. However, the script may be adapted to older versions by a unique and simple change: set the variable "$GnuPlot4OrNewer" at the beginning of the script (in the configuration section) to "false":

$GnuPlot4OrNewer=false
Gnuplot

eplot is based on Gnuplot and needs Gnuplot 4.0 or newer. Older versions are supported but a variable must be changed in the eplot script (see the download section)

Ruby

eplot and ec are completely written in the ruby programming language, so you need to have the ruby runtime package installed. Ruby comes with most Linux distributions.

Credits

eplot was written by Christian Wolf. The dumb terminal patch was provided by Peter Barnes.

Licence

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

eplot's People

Contributors

amake avatar chriswolfvision avatar ernstki avatar jonco3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

eplot's Issues

Output to SVG

Hi,

Thanks for making this tool. Gnuplot has far too many bells and whistles for what I need to do. It would be useful for web nerds if you could output SVG files.

How to use time data as input?

How can I tell eplot that my first column contains timestamps?

I have tried this:

echo '2022-12-15T12:18:26 104.8
2022-12-16T12:36:16 81.36
2022-12-17T14:06:25 79.875' | eplot -d -x 'xdata time; timefmt "%Y-%m-%dT%H:%M:%S"'

and

echo '2022-12-15T12:18:26 104.8
2022-12-16T12:36:16 81.36
2022-12-17T14:06:25 79.875' | eplot -d -x 'xdata time' -x 'timefmt "%Y-%m-%dT%H:%M:%S"'

(and without -x).

But it's still wrong.

(Sorry if my approach is completely wrong. I don't have experience with gnuplot. I just found eplot and thought it would be great if it's really that easy!)

This is the corresponding gnuplot script:

set terminal dumb
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set grid
plot 'data.txt' using 1:2 with lines

EDIT: Simplify tested eplot commands. Add working gnuplot script.

using size parameter results in cropped image

Using a command like
eplot data.txt -s 2

generates a cropped image instead of a complete bigger image.
The command seems to get the image to a higher resolution, but fails to place it in its entirety in a proper "outline"

foo

Using the full terminal

Hi!

I just fount this lil app - awesome!
But im missing an option: how can i enlarge the chart size to use the full terminal instead of its default size?

You can get the current terminal size via stty size but i have no clue about gnuplot so far, maybe you know? How to adjust the chart size?

Disable output of plotting commands by default

It would be nice if the default were not to display the commands used. This is especially helpful when printing results to the terminal. I could just redirect stderr to /dev/null of course, but it would be nice if this wasn't needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.