PLplot 5.9.6
|
00001 /* $Id$ 00002 * 00003 * Routines for drawing error bars and tick marks. 00004 * 00005 * Copyright (C) 2004 Alan W. Irwin 00006 * 00007 * This file is part of PLplot. 00008 * 00009 * PLplot is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Library Public License as published 00011 * by the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * PLplot is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU Library General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Library General Public License 00020 * along with PLplot; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #include "plplotP.h" 00025 00026 /*----------------------------------------------------------------------*\ 00027 * void plxtik() 00028 * 00029 * Draws a tick parallel to x. 00030 \*----------------------------------------------------------------------*/ 00031 00032 void 00033 plxtik( PLINT x, PLINT y, PLINT below, PLINT above ) 00034 { 00035 plP_movphy( x, y - below ); 00036 plP_draphy( x, y + above ); 00037 } 00038 00039 /*----------------------------------------------------------------------*\ 00040 * void plytik() 00041 * 00042 * Draws a tick parallel to y. 00043 \*----------------------------------------------------------------------*/ 00044 00045 void 00046 plytik( PLINT x, PLINT y, PLINT left, PLINT right ) 00047 { 00048 plP_movphy( x - left, y ); 00049 plP_draphy( x + right, y ); 00050 } 00051 00052 /*----------------------------------------------------------------------*\ 00053 * void plstik() 00054 * 00055 * Draws a slanting tick at position (mx,my) (measured in mm) of 00056 * vector length (dx,dy). 00057 \*----------------------------------------------------------------------*/ 00058 00059 void 00060 plstik( PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy ) 00061 { 00062 plP_movphy( plP_mmpcx( mx ), plP_mmpcy( my ) ); 00063 plP_draphy( plP_mmpcx( (PLFLT) ( mx + dx ) ), plP_mmpcy( (PLFLT) ( my + dy ) ) ); 00064 } 00065 00066 /*----------------------------------------------------------------------*\ 00067 * void plerx1() 00068 * 00069 * Plot single horizontal error bar. 00070 \*----------------------------------------------------------------------*/ 00071 00072 static void 00073 plerx1( PLFLT xmin, PLFLT xmax, PLFLT y ) 00074 { 00075 PLINT yminor; 00076 00077 yminor = (PLINT) ( MAX( 1.0, plsc->minht * plsc->ypmm ) ); 00078 plxtik( plP_wcpcx( xmin ), plP_wcpcy( y ), yminor, yminor ); 00079 plP_movwor( xmin, y ); 00080 plP_drawor( xmax, y ); 00081 plxtik( plP_wcpcx( xmax ), plP_wcpcy( y ), yminor, yminor ); 00082 } 00083 00084 /*----------------------------------------------------------------------*\ 00085 * void plery1() 00086 * 00087 * Plot single vertical error bar. 00088 \*----------------------------------------------------------------------*/ 00089 00090 static void 00091 plery1( PLFLT x, PLFLT ymin, PLFLT ymax ) 00092 { 00093 PLINT xminor; 00094 00095 xminor = (PLINT) ( MAX( 1.0, plsc->minht * plsc->xpmm ) ); 00096 plytik( plP_wcpcx( x ), plP_wcpcy( ymin ), xminor, xminor ); 00097 plP_movwor( x, ymin ); 00098 plP_drawor( x, ymax ); 00099 plytik( plP_wcpcx( x ), plP_wcpcy( ymax ), xminor, xminor ); 00100 } 00101 00102 /*----------------------------------------------------------------------*\ 00103 * void plerrx() 00104 * 00105 * Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)). 00106 \*----------------------------------------------------------------------*/ 00107 00108 void 00109 c_plerrx( PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y ) 00110 { 00111 PLINT i; 00112 00113 if ( plsc->level < 3 ) 00114 { 00115 plabort( "plerrx: Please set up window first" ); 00116 return; 00117 } 00118 00119 for ( i = 0; i < n; i++ ) 00120 plerx1( xmin[i], xmax[i], y[i] ); 00121 } 00122 00123 /*----------------------------------------------------------------------*\ 00124 * void plerry() 00125 * 00126 * Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)). 00127 \*----------------------------------------------------------------------*/ 00128 00129 void 00130 c_plerry( PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax ) 00131 { 00132 PLINT i; 00133 00134 if ( plsc->level < 3 ) 00135 { 00136 plabort( "plerry: Please set up window first" ); 00137 return; 00138 } 00139 00140 for ( i = 0; i < n; i++ ) 00141 plery1( x[i], ymin[i], ymax[i] ); 00142 }