GRASS logo


d.linegraph - Generates and displays simple line graphs in the active graphics monitor display frame.


display, cartography


d.linegraph --help
d.linegraph [-xysl] x_file=string y_file=string[,string,...] [directory=string] [y_color=string[,string,...]] [color_table=style] [width=integer[,integer,...]] [title_color=string] [x_title=string] [y_title=string] [title=string] [y_range=min,max] [y_tics=float[,float,...]] [x_scale=float] [y_scale=float] [icon=string] [point_size=float] [secondary_color=name] [secondary_width=integer[,integer,...]] [--help] [--verbose] [--quiet] [--ui]


Scale only X labels, not values
Scale only Y labels, not values
Draw points
Do not draw lines
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


x_file=string [required]
Name of data file for X axis of graph
y_file=string[,string,...] [required]
Name of data file(s) for Y axis of graph
Path to files
Path to the directory where the input files are located
Color for Y data
Name of color table
Options: aspect, aspectcolr, bcyr, bgyr, blues, byg, byr, celsius, corine, curvature, differences, elevation, etopo2, evi, fahrenheit, gdd, grass, greens, grey, grey.eq, grey.log, grey1.0, grey255, gyr, haxby, kelvin, ndvi, ndwi, oranges, population, population_dens, precipitation, precipitation_daily, precipitation_monthly, rainbow, ramp, random, reds, roygbiv, rstcurv, ryb, ryg, sepia, slope, soilmoisture, srtm, srtm_plus, terrain, viridis, water, wave
aspect aspect: aspect oriented grey colors
aspectcolr aspectcolr: aspect oriented rainbow colors
bcyr bcyr: blue through cyan through yellow to red
bgyr bgyr: blue through green through yellow to red
blues blues: white to blue
byg byg: blue through yellow to green
byr byr: blue through yellow to red
celsius celsius: blue to red for degree Celsius temperature
corine corine: EU Corine land cover colors
curvature curvature: for terrain curvatures (from and r.slope.aspect)
differences differences: differences oriented colors
elevation elevation: maps relative ranges of raster values to elevation color ramp
etopo2 etopo2: colors for ETOPO2 worldwide bathymetry/topography
evi evi: enhanced vegetative index colors
fahrenheit fahrenheit: blue to red for Fahrenheit temperature
gdd gdd: accumulated growing degree days
grass grass: GRASS GIS green (perceptually uniform)
greens greens: white to green
grey grey: grey scale
grey.eq grey.eq: histogram-equalized grey scale
grey.log grey.log: histogram logarithmic transformed grey scale
grey1.0 grey1.0: grey scale for raster values between 0.0-1.0
grey255 grey255: grey scale for raster values between 0-255
gyr gyr: green through yellow to red
haxby haxby: relative colors for bathymetry or topography
kelvin kelvin: blue to red for temperature in Kelvin scale
ndvi ndvi: Normalized Difference Vegetation Index colors
ndwi ndwi: Normalized Difference Water Index colors
oranges oranges: white to orange
population population: color table covering human population classification breaks
population_dens population_dens: color table covering human population density classification breaks
precipitation precipitation: precipitation color table (0..2000mm)
precipitation_daily precipitation_daily: precipitation color table (0..1000mm)
precipitation_monthly precipitation_monthly: precipitation color table (0..1000mm)
rainbow rainbow: rainbow color table
ramp ramp: color ramp
random random: random color table
reds reds: white to red
roygbiv roygbiv: no description
rstcurv rstcurv: terrain curvature (from r.resamp.rst)
ryb ryb: red through yellow to blue
ryg ryg: red through yellow to green
sepia sepia: yellowish-brown through to white
slope slope: r.slope.aspect-type slope colors for raster values 0-90
soilmoisture soilmoisture: soilmoisture color table (0.0-1.0)
srtm srtm: color palette for Shuttle Radar Topography Mission elevation
srtm_plus srtm_plus: color palette for Shuttle Radar Topography Mission elevation (with seafloor colors)
terrain terrain: global elevation color table covering -11000 to +8850m
viridis viridis: perceptually uniform sequential color table viridis
water water: water depth
wave wave: color wave
Width of the lines
Color for axis, tics, numbers, and title
Default: black
Title for X data
Title for Y data
Title for Graph
Minimum and maximun value for Y axis (min,max)
Tic values for the Y axis
Scale for X values
Scale for Y values
Symbol for point
Options: basic/arrow, basic/arrow1, basic/arrow2, basic/arrow3, basic/box, basic/circle, basic/cross1, basic/cross2, basic/cross3, basic/diamond, basic/hexagon, basic/marker, basic/octagon, basic/pin, basic/pin_dot, basic/point, basic/pushpin, basic/star, basic/triangle, basic/x, demo/muchomurka, demo/smrk, extra/4pt_star, extra/adcp, extra/airport, extra/alpha_flag, extra/bridge, extra/dim_arrow, extra/dive_flag, extra/fiducial, extra/fish, extra/half-box, extra/half-circle, extra/offbox_ne, extra/offbox_nw, extra/offbox_se, extra/offbox_sw, extra/pentagon, extra/ping, extra/ring, extra/simple_zia, extra/target, geology/circle_cross, geology/half-arrow_left, geology/half-arrow_right, geology/strike_box, geology/strike_circle, geology/strike_cleavage, geology/strike_half-bowtie, geology/strike_line, geology/strike_parallel, geology/strike_triangle, legend/area, legend/area_curved, legend/line, legend/line_crooked, n_arrows/basic_compass, n_arrows/fancy_compass, n_arrows/n_arrow1a, n_arrows/n_arrow1b, n_arrows/n_arrow2, n_arrows/n_arrow3, n_arrows/n_arrow4, n_arrows/n_arrow5, n_arrows/n_arrow6, n_arrows/n_arrow7a, n_arrows/n_arrow7b, n_arrows/n_arrow8a, n_arrows/n_arrow8b, n_arrows/n_arrow9
Default: basic/circle
Point size
Default: 5
Color for point symbol edge color
Default: black
Width of point symbol lines
Default: 0.1

Table of contents


d.linegraph is a module to draw simple x,y line graphs (plots) based on numerical data contained in separate files.

Data format

The X and Y data files for the graph are essentially a column of numbers in each file, with one input number per line. The program expects that each X value will have a corresponding Y value, therefore the number of lines in each data input file should be the same. Essentially, the X data becomes the X axis reference to which the Y data is plotted as a line. Therefore, the X data should be a monotonically increasing progression of numbers (i.e. "1,2,3,..."; "0, 10, 100, 1000,..."; "...-5,-1,0,1,5..."). If multiple Y data files are used, the Y axis scale will be based on the range of minimum and maximum values from all Y files, then all Y data given will be graphed according to that Y scale. Therefore, if multiple Y data inputs are used with dissimilar units, the graph produced comparing the two will be deceptive.

File inputs

If the directory option is provided, the paths to files can (and should) be only relative paths to these files. While this is not recommended for scripting, it can be advantageous when typing the paths manually. For example when all files are stored in the directory /home/john/data, the user can provide the following in the command line:
d.linegraph directory=/home/john/data x_file=x.txt y_file=y1.txt,y2.txt

Managing colors

The user can specify the y_color option, the color_table option or just leave the defaults to influence the color of the plotted lines.

Colors specified by y_color option are used for drawing the lines in the graph. If multiple Y data files are used, an equal number of colors may be used to control the colors of the lines. Colors will be assigned to Y data in respect to the sequence of instantiation on the command line. It can be one of GRASS GIS named colors or the RGB values from 0-255 separated by colons (RRR:GGG:BBB).

Alternatively, the user can use the color_table option to specify one of the GRASS GIS predefined color tables.

By default, a series of colors will be chosen by the module if none are provided upon invocation. The order of default colors is red, green, violet, blue, orange, gray, brown, magenta, white, and indigo. The user is advised not to rely on the order of default colors but to either use the y_color or the color_table option to obtain predictable and reproducible results.

The color to be used for titles, axis lines, tics, and scale numbers is determined by the title_color option. The user can provide one of the GRASS GIS named colors (such as gray, white, or black) or use the GRASS GIS colon-separated format for RGB (RRR:GGG:BBB).

Titles, labels, and tics

The title option specifies the text for the title of the graph. It will be centered over the top of graph. The x_title option is a text to describe data for X axis. It will be centered beneath the graph. Default is no text unless there is a need for a unit descriptor determined by the d.linegraph module, then string such as "in hundreds" is generated. The y_title option is a text to describe data for Y axis. It will be centered beneath the X data description. Similarly, to the x_title option, default is no text unless there is a need for an auto-generated description. In the case of graphs with multiple lines (multiple inputs for Y axis), user may wish to use more specific text placement using the d.text or v.label programs.


For historical reasons, the d.linegraph module accepts titles of more than one word where the underscore character ("_") is used to represent spaces (" "). For example "Census_data_1990" would be printed over the graph as "Census data 1990". The use of underscores is not necessary to use as long as the parameter is quoted in the command line. In general, use of underscores is not recommended and there is no need to use it at all in the GUI or when using d.linegraph in Python scripts.

The way the program locates and labels tic marks is less than perfect:
1) although distances between Y tics are proportional to the value, they are not proportional on the X axis;
2) decimal values between -1 and 1 can be printed on the X axis, but not on Y. (With respect to the later, the input for Y values can all be multiplied by a factor of 10 before graphing).

Depending on the user's needs, it might be easier or more appropriate to use a 3rd party tool such as xgraph, gnuplot, Matplotlib in Python, or R instead of d.linegraph. For a more general solution for plotting in GRASS GIS, the user is advised to use the d.graph module.


The following can be executed in Bash to create the input data for this example. The user can just create these files in a text editor, save them and specify path to them.
cat > x.txt <<EOF
cat > y1.txt <<EOF
cat > y2.txt <<EOF

The next command sequence creates a file plot.png in the current directory which is the drawing made by d.linegraph.

d.mon start=cairo output=plot.png width=400 height=400
d.linegraph x_file=x.txt y_file=y1.txt,y2.txt
d.mon stop=cairo


d.frame, d.text, v.label, d.graph, d.histogram


Chris Rewerts, Agricultural Engineering, Purdue University

Last changed: $Date: 2017-02-02 01:10:41 -0800 (Thu, 02 Feb 2017) $


Available at: d.linegraph source code (history)

Main index | Display index | Topics index | Keywords index | Graphical index | Full index

© 2003-2017 GRASS Development Team, GRASS GIS 7.5.svn Reference Manual