Advanced Programming Tips; Filling And Hatching - HP 7470A Interfacing And Programming Manual

Graphic plotter
Hide thumbs Also See for HP 7470A:
Table of Contents

Advertisement

)
) 320 PRINT "LT"
330 FOR X-1 TO 12
i 340 REHD Y
350 PRINT "PR";X;Y;"PD"
i 360 NEXT X
' 3?0 PRINT "PUB,1G5PD7.1,165PU"
v
I 380 PRINT "SP1;LT4,G"
390 GOSUB 1000
/
, 4 0 0 DRTH " J" , " F" , " M" ," R" , " M" ,"J" , " J" , " R" , " S" , " 0" , " N" , " D"
410 DRTR
55,60,63,62,59,54,50,46,47,49,53,58
> 420 STOP
1000 ! PLOTTING SUBROUTINE
) 1010 RERD X,Y,P
1020 IF P-1 THEN PRINT "PD";X;Y
, 1030 IF P-0 THEN PRINT "PU";X;Y
v
1040 IF P-3 THEN 1090
, \ 1050 DRTfl 1,98,0,2,100,1,3,102,1,4,105,1,5,107,1,6,110,1
' 1060 DRTR
7,125,1,6,112,1,9,115,1,10,125,1,11,130,1
\ 1070 DRTR 12, 1 . " ! 2 , 1 ,0,0,3
1080 GOTO 1010
\ 1090 PRINT "LT4,6 PU3.2,165 PD4.7,165SPO; "
'
1100 RETURN
, \ 1110 END
: dvanced Programming Tips
FUling and Hatching
Two kinds of area fill are commonly used in bar graphs and pie charts;
'
, ) solid fill and hatching. Solid fill totally covers the area with color,
;■ . whereas hatching fills the area with evenly spaced parallel lines. If
there are lines in two directions at 90 degree angles, we call the
'
) hatching crosshatching. Sometimes a graph will have both narrow
and wide hatching or crosshatching, the wide hatching having more
y
' space between the lines than the narrow.
J. Jling a Bar
The following two program segments, together with lines 10 to 100 and
, , 400 of this chapter's program, will each fill a bar which represents the
' March data for line 1, i.e., 3,18 (see line 260, in the program). To create
, ) an aesthetically pleasing and easily comprehendible bar graph, the bar
is centered over the X data point and is slightly wider than one-half the
'
distance between data points on the X-axis. The increment variable P
i
depends on pen width. A value of P = 20 plotter units is suitable for a
wide pen and 10 for a narrow pen.
The first program segment should be used when plotting on paper.
v " ) Notice the peri does not lift; the routine is faster and prolongs pen-tip
life by limiting up/down moves. The second segment should be used
when plotting on transparency film to achieve uniform ink distribution.
''' ' )
f - | 0
PUTTING THE COMMANDS TO WORK
. )
The first routine performs the following tasks:
1. Obtains, in plotter units, the coordinates of the corners of the bar.
2. Turns scaling off so plotting is in plotter units. This routine can,
therefore, be used in any program, and there is no need to recompute
the increment P for different scaling in different graphs.
3. Beginning at the X,Y
m
in value, draws a line to the top of the bar,
moves over slightly less t h a n one pen width, and draws to the
bottom of the bar.
4. Increments the X-value one pen width and repeats step 3 until the
bar is filled.
5. Rescales the plot to the original scaling.
The second routine repeatedly moves with the pen up to the X-coordinate
at the base of the bar and draws a line to the top of the bar. All fill lines
are drawn in the same direction.
Segment
1 — Plotting
on
Paper
120 PRINT
" P R 2 . 7 , 0 , P D , 2 . 7 , 1 8 , 3 . 3 , 1 8 , 3 . 3 , 0 , 2 . ? , 0 ; P U ; "
130 PRINT " O R ; "
140 ENTER 705 ;
R , B , C
150 PRINT
" P R 2 . 7 , 1 8 ; O R ; "
160 ENTER 705 ;
D , E , F
170 PRINT
" P R 3 . 3 , 1 8 ; 0 R ; "
180 ENTER 705 ;
G , H , I
190 PRINT
" P R 2 . 7 , 0 ; S C ; "
200
P - 2 0
2 1 0 FOR X«R TO G-P STEP 2 * P
220 PRINT
" P D " ; X ; B ; X ; E
230 PRINT
" P D " ; X + P ; E ; X + P ; B
240 NEXT X
250 PRINT
" P U ; S C 1 , 1 2 , 0 , 1 5 0 ; "
Segment
2 — Plotting
on Transparency
Film
120 PRINT
" P R 2 . 7 , 0 , P D , 2 . 7 , 1 8 , 3 . 3 , 1 8 , 3 . 3 , 0 , 2 . 7 , 0 ; P U ; "
130 PRINT " O R ; "
140 ENTER 705 ;
R,B,C
150 PRINT
" P R 2 . 7 , 1 8 ; 0 R ; "
160 ENTER 705 ;
D , E , F
170 PRINT
" P R 3 . 3 , 1 8 ; 0 R ; "
180 ENTER 705 ;
G , H , I
190 PRINT
" P R 2 . 7 , 0 ; S C ; "
200
P-20
210 FOR X = R TO G STEP P
220 PRINT " P U " ; X ; B ; " P D " ; X ; E
230 NEXT X
240 PRINT
" P U ; S C 1 , 1 2 , 0 , 1 5 0 ; "
PUTTING THE COMMANDS TO WORK
8-11

Advertisement

Table of Contents
loading

Table of Contents