You are on page 1of 2



The Graphical Display of Data

10.1.INTRODUCTION TO GRAPHS Specifying a Coordinate System • • •
picBox.Scale (a,d) - (b,c)

: specifies x-axis range from a to b, and y-axis range from c to d.

The ordered pair (a,d) gives the coordinates of the top left corner of the picture box. The ordered pair (b,c) gives the coordinates of the lower right corner of the picture box.

Graphics Methods for Drawing Lines, Points, and Circles • • •
picBox.Line (x1,y1) - (x2,y2) picBox.PSet(x,y) picBox.Circle(x,y),r

: draws line segment from (x1,y1) to (x2,y2) in picture box.

: plots the point (x,y). : draws the circle with center (x,y) and radius r (in x axis units).

Positioning Text • • • A picture box has two properties (CurrentX, CurrentY) and two methods (TextHeight,TextWidth) that allow us to precisely position text alongside graphics. CurrentX and CurrentY record the precise horizontal and vertical location at which the next character will be printed. CurrentY is the location for the top of the character cursor.

Obtaining a good range of values for a graph with only positive values picOutput.Scale (-0.2 * r, 1.2 * h) - (1.2 *r, -0.2 * h) where r = x coordinate of the rightmost point to be drawn, h = y coordinate of the highest point to be drawn. Line clipping If one or more points in a graphics method fall outside the picture box part of the line is clipped. More than one Scale statements • • A program can execute a picOutput.Scale statement more than once. The new statements have no effect on text and graphs already drawn; however, future graphics statements will use the new coordinate system.


. .Circle (x..y).y2)..-..-. To avoid this problem use a = 0.y1) .a * c. picBox.-. See Figure 10.LINE CHARTS • • • Line charts (x-y plots) represent y = f(x) as lines and data points..--..Line (x1. and let 0< a < b < 1.y2). . picBox. BAR CHARTS • • • Bar charts (e. and b*c = 2πb.- 10. then the radius corresponding to that point is not plotted.--..000001.(x2.. . .28 for different styles. and circles in color place a vbColor constant at the end of the corresponding command. • • Use the FillStyle property to fill the circular sector.-.Producing colorful displays • • To draw lines.Circle (x.-.) are produced by drawing rectangles using a variation of the line statement. rather than a = 0. s = 3 . 2 . and b*c = 2πb.(x2.. r..y1) ..--. then the statement picBox..DrawStyle = s to select different line styles s = 0 ______________________ s=1_ _ _ _ _ _ _ _ _ _ _ s=2. etc. r.2 of the textbook.y1) . Example: picBox..10. PIE CHARTS • • Pie charts are produced by drawing circular sectors using the Circle and Line statements.. points. BF : produces a filled rectangle.. B : produces a blank rectangle. • Also... Describe legend to identify more than one curve if needed.Line (x1. vbRed 10.. Use labels for the axes and plot.. See examples in section 10..(x2.2. histograms. the statement picBox...b * c plots the circular sector limited by the angles a*c = 2πa.y2). Note: when a = 0.. ..-..--. Line Styling • Use the statement picBox. b * c plots the circular arc limited by the angles a*c = 2πa..3...Line (x1. Let c = 2π be the circumference of a unit circle.y).-s = 4 .FillColor = vbColor (a vbColor constant) for colorful sectors. a * c. Use the statement picBox.g.4.