d.graph(1grass)
π d.graph β bestie, let's draw on the monitor π
okay so this is the GRASS User's Manual page for d.graph, and it's genuinely one of the most fun little tools in the whole display family. it makes and shows simple graphics right on the display monitor. no cap. π¨β¨
β¨ NAME β¨
d.graph β program for generating and displaying simple graphics on the display monitor. iconic behaviour, honestly. π¦
π·οΈ KEYWORDS π·οΈ
display, cartography
π SYNOPSIS π
d.graph
d.graph --help
d.graph [-m] [input=name] [color=string] [--help] [--verbose]
[--quiet] [--ui]
π© Flags π©
-mβ Coordinates are given in map units--helpβ Print usage summary--verboseβ Verbose module output--quietβ Quiet module output--uiβ Force launching GUI dialog
π Parameters π
input=nameβ Name of file containing graphics commands, if not given reads from standard inputcolor=stringβ Color to draw with, either a standard GRASS color orR:G:Btriplet Default:black
πΈ DESCRIPTION πΈ
so d.graph draws graphics that are described either from standard input (that's the default vibe), or from within a file (if you hand it an input file name on the command line, bestie). and listen β if you're typing those graphics commands in from standard input, you signal the end of input with a CTRL-d. yes, Ctrl+D is the finisher. π
coordinates get given either as a percentage of frame height and width (default mode, slay) or in geographic coordinates (when you pass the -m flag). πΊοΈ
you can run this program interactively or non-interactively, and both are valid:
- run it completely non-interactively by specifying the name of a graphics file containing the
d.graphgraphics commands. and if you run non-interactively, thed.graphcommand gets saved to the display'sdedrawhistory. π§Ύβ¨ - run it partially interactively by specifying any/all of the parameters except the graphics file
input=nameparameter on the command line. in that cased.graphexpects you to typed.graphgraphics commands from standard input (i.e., the keyboard) and it will (silently) prompt you for those graphics commands. sneaky but polite. π€« - OR you can simply type
d.graphon the command line and get prompted for the values of all parameters. in this case you get the standard GRASS GUI interface. main character energy. π«Ά
the default coordinate system is 0-100 percent of the active frame in x and, same deal, 0-100 in y β and that's true regardless of the graphics monitor display frame size and aspect. the (0,0) location is the lower left corner of the active graphics monitor display frame. all values may be floating point. and if the -m flag is given, geographic coordinates get used instead. periodt. π
π¨ COMMANDS π¨
the graphics language is simple, and uses the following commands:
[ # | move | draw | polygon | polyline | color | text | size | symbol | rotation | icon | width ]
#comment β a line of comment which is ignored in the processing. (your little diary entry, ignored fr fr π)move xpos yposβ the current location is updated to xpos ypos. unless the-mflag is used, values are stated as a percent of the active display frame's horizontal (xpos) and vertical (ypos) size, and may be floating point values. values are between 0-100. Note. a space must separate xpos and ypos. β οΈdraw xpos yposβ a line is drawn in the current color from the current location to the new location xpos ypos, which then becomes the current location. unless the-mflag is used, values are stated as a percent of the active display frame's horizontal (xpos) and vertical (ypos) size, and may be floating point values. values are between 0-100. Note. a space must separate xpos and ypos. βοΈpolygon xpos ypos xpos ypos ...β the coordinates appearing beneath the wordpolygon, one pair per line, circumscribe a polygon that is to be filled with the current color. π£polyline xpos ypos xpos ypos ...β the coordinates appearing beneath the wordpolyline, one pair per line, circumscribe a polygon that is not to be filled with color. γ°οΈcolor colorβ sets the current color to that stated; subsequent graphics will be drawn in the stated color, until the current color is set to a different color. options arered,orange,yellow,green,blue,indigo,violet,brown,magenta,gray,white,black, anR:G:Btriplet (separated by colons), or the word"none"(draws in the default background color). πtext line-of-textβ the stated text is drawn at the current location using the current color, and the new current location is then positioned at the end of the text string. βοΈsize xper yperβ subsequent text will be drawn such that the text is xper percent of the graphics monitor display frame wide and yper percent of the frame high. by default, the text size is set to 5 percent of the active frame's width and 5 percent of the frame's height. if only one value is given, then that value will be used for both x and y scaling. Note. a space must separate xper and yper. β οΈsymbol type size xper yper [line_color [fill_color]]β a symbol is drawn at the given size on the display monitor. the xper and yper options define the center of the icon and are given as a percentage of the display frame (0,0is lower left). the symbol can be any of those stored in$GISBASE/etc/symbol/(e.g.basic/circle) or stored in the user's mapset directory in the form$MAPSET/symbol/type/name. the colors may be either a standard color name, anR:G:Btriplet, or"none". if using anR:G:Btriplet, each color value can range from 0-255. if not specified the default line_color isblackand the default fill_color isgrey. βrotation angleβ subsequent text and symbols will be drawn such that they are rotated angle degrees counter-clockwise from east. πicon type size x yβ draws an icon of typeso,x, or+with specified size (in %) at location x,y. Note: typeodesignates a square. π²width valueβ subsequent lines (including non-FreeType text) will be drawn with the given pixel thickness. the default value is0.
π EXAMPLES π
for an example use of d.graph, examine the contents of the command file grass_logo.txt located in the d.graph source code directory. it will draw the CERL GRASS logo using the d.graph graphing commands stored in the file. note that the coordinates in the grass_logo.txt file were taken directly off an image drawn by hand on graph paper. π (artisanal. handcrafted. we love to see it.)
a dynamic example can be found in the d.polar shell script.
β Draw a "star" symbol at a given map coordinate
echo "symbol basic/star 20 2264417 5413182 black red" | d.graph -m
π² Split the screen into quadrants:
d.frame -s full_screen
d.graph << EOF
color 80:80:120
polygon
0 49.75
0 50.25
100 50.25
100 49.75
polygon
49.85 0
50.15 0
50.15 100
49.85 100
EOF
π§ NOTES π§
d.graph remembers the last screen location (xpos ypos) to which the user moved β even after the user erases the display frame. so if you run d.graph repeatedly and you want to start anew with the default (xpos ypos) screen location, you should clear the display frame between runs of d.graph. she has memory, bestie. ππ
π LIMITATIONS π
there are no automated ways of generating graphic images. it is anticipated that GRASS user sites will write programs to convert output from a resident graphics editor into GRASS d.graph format. (e.g. EPS -> d.graph, perhaps with the help of a pstoedit plugin.) so yeah, DIY era. π οΈ
π SEE ALSO π
d.font, d.labels, d.polar, d.text, d.where
π AUTHOR π
James Westervelt, U.S. Army Construction Engineering Research Laboratory
π¦ SOURCE CODE π¦
available at: d.graph source code (history)
latest change: Tuesday Feb 18 17:20:26 2025 in commit: 688e625e7db3be9a465ce99ba25f36d2ebdd5aeb
Main index | Display index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page, bestie!! π«Ά this one's been living in the docs since way back, and the copyright line says Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual β so shoutout to the GRASS Dev Team for keeping it going all these years. the footer of this manual page literally reads GRASS 8.5.0 on one side and d.graph(1grass) on the other. go draw something cute!! πβ¨ππ¦πΈ
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms