Prev: legendbox.html Up Next: plotting-data.html
Line

Practical Guide:
line::pdraw(2*CM,3*MM)(2*CM,3*CM)(4*CM,4*CM);  // draw a line between the given coordinates, 
                                               // into the current pad ( <== the initial 'p')

line::fdraw(x1len(3),y1len(5))(x1len(10),y1len(15)).arrow(true).linewidth(2*MM);
                                               // draw an arrow from the axis-coordinates (3,5)
                                               // to (10,15)

A line is a polygon between points, which are specifyed using length-pairs. A line can be plotted into the current pad using the pdraw function. This function takes two length arguments, this will be the starting point of the line. Specifying only one point, however, does not have too much meaning (such a 'line' will not appear on the terminal). The possibility to add an arbitrary number of points in a consequent and easy way is provided via the parenthesis operator (operator()), which takes again two length parameters (the coordinates of the new point to be added). This operator returns a reference to the line itself, so that the same operator can be called again:

    line::pdraw(MM,CM)(MM,5*CM)(3*CM,5*CM);
(However, with the current version of CINT, 1.5.99, it does not work yet, I hope it will soon be corrected.).

To draw a line into the current frame or canvas, the fdraw and cdraw functions are provided, with the same characteristics.

To set other properties of the line, you can call the following member functions on the returned reference:

    line &linewidth(const length &);    // set the linewidth
    line &lw(const length &)            // shorthand version of the previous
    const length &linewidth() const;    // get the linewidth

    ... etc (see the source file :-)

In addition you can specify if arrows at the ends of the line should be drawn. The arrow at the starting point of the line is called a 'back-arrow', the arrow at the last point of the line is called 'forward-arrow', or simply arrow. By default they are not drawn, and they can be switched on/off by the

    arrow(bool);         // switch the forward arrow
    arrow_back(bool);    // switch the backward arrow
member functions. You can set other properties of the arrows as well, like the angle (arrowangle(double) or arrowangle_back(double), in degrees), or length (arrowlength(const length &) or arrowlength_back(const length &) ), see the picture below.

If you often draw arrow in your figures, you can put the following into your ~/.blop/bloprc.C file in your home directory:

    // draw an arrow in the current frame
    line &farrow(const length &x1, const length &y1,
                 const length &x2, const length &y2)
    {
       return line::fdraw(x1,y1)(x2,y2).arrow(true);
    }

Source files:
   line.h
   line.cc

Prev: legendbox.html Up Next: plotting-data.html