Back to index

plt-scheme  4.2.1
pltick.c
Go to the documentation of this file.
00001 /* $Id: pltick.c,v 1.2 2005/03/17 21:39:21 eli Exp $
00002 
00003        Routines for drawing error bars and tick marks.
00004 */
00005 
00006 #include "plplotP.h"
00007 
00008 /*----------------------------------------------------------------------*\
00009  * void plxtik()
00010  *
00011  * Draws a tick parallel to x.
00012 \*----------------------------------------------------------------------*/
00013 
00014 void
00015 plxtik(PLINT x, PLINT y, PLINT below, PLINT above)
00016 {
00017     plP_draphy(x, y);
00018 
00019     if (below != 0)
00020        plP_draphy(x, y - below);
00021 
00022     if (above != 0)
00023        plP_draphy(x, y + above);
00024 
00025     plP_draphy(x, y);
00026 }
00027 
00028 /*----------------------------------------------------------------------*\
00029  * void plytik()
00030  *
00031  * Draws a tick parallel to y.
00032 \*----------------------------------------------------------------------*/
00033 
00034 void
00035 plytik(PLINT x, PLINT y, PLINT left, PLINT right)
00036 {
00037     plP_draphy(x, y);
00038 
00039     if (left != 0)
00040        plP_draphy(x - left, y);
00041 
00042     if (right != 0)
00043        plP_draphy(x + right, y);
00044 
00045     plP_draphy(x, y);
00046 }
00047 
00048 /*----------------------------------------------------------------------*\
00049  * void plstik()
00050  *
00051  * Draws a slanting tick at position (mx,my) (measured in mm) of
00052  * vector length (dx,dy).
00053 \*----------------------------------------------------------------------*/
00054 
00055 void 
00056 plstik(PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy)
00057 {
00058     plP_draphy(plP_mmpcx(mx), plP_mmpcy(my));
00059     plP_draphy(plP_mmpcx((PLFLT) (mx + dx)), plP_mmpcy((PLFLT) (my + dy)));
00060     plP_draphy(plP_mmpcx(mx), plP_mmpcy(my));
00061 }
00062 
00063 /*----------------------------------------------------------------------*\
00064  * void plerx1()
00065  *
00066  * Plot single horizontal error bar.
00067 \*----------------------------------------------------------------------*/
00068 
00069 static void
00070 plerx1(PLFLT xmin, PLFLT xmax, PLFLT y)
00071 {
00072     PLINT yminor;
00073 
00074     yminor = MAX(1.0, plsc->minht * plsc->ypmm);
00075     plP_movwor(xmin, y);
00076     plxtik(plP_wcpcx(xmin), plP_wcpcy(y), yminor, yminor);
00077     plP_drawor(xmax, y);
00078     plxtik(plP_wcpcx(xmax), plP_wcpcy(y), yminor, yminor);
00079 }
00080 
00081 /*----------------------------------------------------------------------*\
00082  * void plery1()
00083  *
00084  * Plot single vertical error bar.
00085 \*----------------------------------------------------------------------*/
00086 
00087 static void
00088 plery1(PLFLT x, PLFLT ymin, PLFLT ymax)
00089 {
00090     PLINT xminor;
00091 
00092     xminor = MAX(1.0, plsc->minht * plsc->xpmm);
00093     plP_movwor(x, ymin);
00094     plytik(plP_wcpcx(x), plP_wcpcy(ymin), xminor, xminor);
00095     plP_drawor(x, ymax);
00096     plytik(plP_wcpcx(x), plP_wcpcy(ymax), xminor, xminor);
00097 }
00098 
00099 /*----------------------------------------------------------------------*\
00100  * void plerrx()
00101  *
00102  * Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)).
00103 \*----------------------------------------------------------------------*/
00104 
00105 MZ_DLLEXPORT
00106 void
00107 c_plerrx(PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y)
00108 {
00109     PLINT i;
00110 
00111     if (plsc->level < 3) {
00112        plabort("plerrx: Please set up window first");
00113        return;
00114     }
00115 
00116     for (i = 0; i < n; i++)
00117        plerx1(xmin[i], xmax[i], y[i]);
00118 }
00119 
00120 /*----------------------------------------------------------------------*\
00121  * void plerry()
00122  *
00123  * Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)).
00124 \*----------------------------------------------------------------------*/
00125 
00126 MZ_DLLEXPORT
00127 void
00128 c_plerry(PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax)
00129 {
00130     PLINT i;
00131 
00132     if (plsc->level < 3) {
00133        plabort("plerry: Please set up window first");
00134        return;
00135     }
00136 
00137     for (i = 0; i < n; i++)
00138        plery1(x[i], ymin[i], ymax[i]);
00139 }