Last active
July 23, 2022 17:03
-
-
Save Gavinok/e06d12ea5f1a2d217ab8455fd27058f6 to your computer and use it in GitHub Desktop.
Example file for using grap with groff and other troff implementations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ft CW | |
groff -G -ms -Tpdf grap.ms > grap.pdf | |
.ft | |
.NH | |
Simple example | |
.LP | |
.G1 | |
54.2 | |
49.4 | |
49.2 | |
50.0 | |
48.2 | |
44.60 | |
.G2 | |
.NH | |
Coordinates | |
.LP | |
by default it will go wherever you say | |
.G1 | |
1 45.2 | |
2 3.2 | |
3 65.2 | |
4 54.2 | |
5 53.16 | |
6 42.2 | |
.G2 | |
.NH | |
Lines | |
.LP | |
.G1 | |
draw solid | |
1 45.2 | |
2 3.2 | |
3 65.2 | |
4 54.2 | |
5 53.16 | |
6 42.2 | |
.G2 | |
.NH | |
External data | |
.LP | |
.G1 | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH | |
Labels | |
.LP | |
.LP | |
Some versions of grap implement labels differently | |
.IP \(bu | |
plan9 | |
.RS | |
.IP \(bu | |
has them always aligned horizontally | |
.RE | |
.LP | |
.G1 | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH | |
Framing | |
.LP | |
.G1 | |
frame ht 3 wid 3 | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH 2 | |
shorter | |
.LP | |
.G1 | |
frame ht 1 wid 3 | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH 2 | |
Wider | |
.LP | |
.G1 | |
frame ht 2 wid 5 | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH 2 | |
Removing Parts Of The Frame | |
.LP | |
.G1 | |
# invisable top | |
frame invis ht 2 wid 5 left solid bot solid | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH 2 | |
No frame | |
.LP | |
.G1 | |
frame invis ht 2 wid 5 | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH 2 | |
Adding a grid | |
.LP | |
.G1 | |
# vertical | |
grid dotted bot from 0 to 7 by 1 | |
# horizontal | |
grid dotted left from 0 to 70 by 5 | |
label left "Time" "(seconds)" | |
label bot "Miss spells when typing" | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH | |
Setting coordinate range | |
.LP | |
.G1 | |
#------------------ | |
coord x 0,11 y 0,70 | |
#------------------ | |
draw solid | |
copy "tmp.dat" | |
.G2 | |
.NH | |
Adding text markings | |
.LP | |
.G1 | |
#-------- | |
"times" above at 5,6 | |
times at 5,6 | |
"bullet" above at 4,5 | |
bullet at 4,5 | |
"vtick" above at 3,4 | |
vtick at 3,4 | |
"circle" above at 1,1 | |
circle at 1,1 radius 0.01 | |
#------- | |
.G2 | |
.NH | |
Copy Thru Command | |
.LP | |
.NH 2 | |
Bar Graph | |
.LP | |
.G1 | |
frame invis bot solid | |
coord x 1,9 | |
# by says how much to increase by | |
copy "tmp.dat" thru { | |
line from $1,0 to $1,$2 | |
line from $1,$2 to $1+1,$2 | |
line from $1+1,$2 to $1+1,0 | |
} | |
.G2 | |
.NH | |
Dotted Line Graph | |
.LP | |
.G1 | |
draw solid | |
# by says how much to increase by | |
pi=atan2(0,-1) | |
copy "tmp.dat" thru { | |
line dotted from $1+.5,0 to $1+.5,$2 | |
"\(bu" size -3 at $1+.5,$2 | |
} | |
.G2 | |
.NH | |
Box Plot | |
.LP | |
This is from the manual page | |
.fam CM | |
.G1 | |
frame invis ht 4 wid 3 bot solid | |
ticks off | |
coord x .5,3.5 y 0,25 | |
define Ht X | |
"- $1,000 -" size -3 at 2,$1 | |
X | |
Ht(5); Ht(10); Ht(15); Ht(20) | |
"Highest Point" "in 50 States" at 1,23 | |
"Heights of" "219 Volcanoes" at 3,23 | |
"Feet" at 2,21.5; arrow from 2,22.5 to 2,24 | |
define box X #(x,min,25%,median,75%,max,minname,maxname) | |
xc=$1; xl=xc-boxwidth/2; xh=xc+boxwidth/2 | |
y1=$2; y2=$3; y3=$4; y4=$5; y5=$6 | |
bullet at xc,y1 | |
" $7" size -3 ljust at (xc,y1) | |
line from (xc,y1) to (xc,y2) # lo whisker | |
line from (xl,y2) to (xh,y2) # box bot | |
line from (xl,y3) to (xh,y3) # box mid | |
line from (xl,y4) to (xh,y4) # box top | |
line from (xl,y2) to (xl,y4) # box left | |
line from (xh,y2) to (xh,y4) # box right | |
line from (xc,y4) to (xc,y5) # hi whisker | |
bullet at xc,y5 | |
" $8" size -3 ljust at (xc,y5) | |
X | |
boxwidth=.3 | |
box(1, .3, 2.0, 4.6, 11.2, 20.3, Florida, Alaska) | |
box(3, .2, 3.7, 6.5, 9.5, 19.9, Ilhanova, Guallatiri) | |
.G2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment