Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

plot_ts.c File Reference

#include "coxplot.h"
#include <math.h>

Go to the source code of this file.


Defines

#define WAY_BIG   1.e+10
#define NCLR_MAX   19
#define STGOOD(s)   ( (s) != NULL && (s)[0] != '\0' )
#define SY   0.07

Functions

float p10 (float x)
void plot_ts_xypush (int a, int b)
void plot_ts_xfix (int nax, int max, float xb, float xt)
void plot_ts_yfix (int nay, int may, float yb, float yt)
void init_colors (void)
MEM_plotdataplot_ts_mem (int nx, float *x, int ny, int ymask, float **y, char *lab_xxx, char *lab_yyy, char *lab_top, char **nam_yyy)
void plot_ts_lab (Display *dpy, int nx, float *x, int ny, float **y, char *lab_xxx, char *lab_yyy, char *lab_top, char **nam_yyy, void_func *killfunc)
MEM_topshell_dataplot_ts_init (Display *dpy, float xbot, float xtop, int ny, float ybot, float ytop, char *lab_xxx, char *lab_yyy, char *lab_top, char **nam_yyy, void_func *killfunc)
void plot_ts_addto (MEM_topshell_data *mp, int nx, float *x, int ny, float **y)

Variables

float ccc [NCLR_MAX][3]
int NCLR = 4
int ilab [4] = { 0,2,3,1 }
float THIK = 0.003
int xpush = 1
int ypush = 1
float xxbot
float xxtop
float yybot
float yytop
int nnaxx = -1
int mmaxx = -1
int nnayy = -1
int mmayy = -1

Define Documentation

#define NCLR_MAX   19
 

Definition at line 16 of file plot_ts.c.

Referenced by init_colors().

#define STGOOD      ( (s) != NULL && (s)[0] != '\0' )
 

Definition at line 28 of file plot_ts.c.

#define SY   0.07
 

Definition at line 30 of file plot_ts.c.

Referenced by plot_ts_addto(), plot_ts_init(), and plot_ts_mem().

#define WAY_BIG   1.e+10
 

Definition at line 10 of file plot_ts.c.

Referenced by plot_ts_addto(), and plot_ts_mem().


Function Documentation

void init_colors void    [static]
 

Definition at line 56 of file plot_ts.c.

References ccc, getenv(), NCLR, NCLR_MAX, strtod(), and THIK.

Referenced by plot_ts_addto(), plot_ts_init(), and plot_ts_mem().

00057 {
00058    static int first=1 ;
00059    char ename[32] , *eee ;
00060    float rf,gf,bf ;
00061    int ii ;
00062 
00063    if( !first ) return ;
00064    first = 0 ;
00065 
00066    /* init ii to 0 (was 1) to match README.environment   19 May 2004 [rickr] */
00067    for( ii=0 ; ii < NCLR_MAX ; ii++ ){
00068      sprintf(ename,"AFNI_1DPLOT_COLOR_%02d",ii+1) ;
00069      eee = getenv(ename) ;
00070      if( eee == NULL && ii < 9 ){    /** 21 Apr 2005: check alternatives **/
00071        sprintf(ename,"AFNI_1DPLOT_COLOR_%1d",ii+1) ; eee = getenv(ename) ;
00072      }
00073      if( eee == NULL && ii <= 9 ){
00074        sprintf(ename,"AFNI_1DPLOT_COLOR_O%1d",ii+1) ; eee = getenv(ename) ;
00075      }
00076      if( eee != NULL ){
00077        rf=gf=bf = -1.0 ;
00078        sscanf( eee , "rgbi:%f/%f/%f" , &rf,&gf,&bf ) ;
00079        if( rf >= 0.0 && rf <= 1.0 && gf >= 0.0 && gf <= 1.0 && bf >= 0.0 && bf <= 1.0 ){
00080          ccc[ii][0] = rf ; ccc[ii][1] = gf ; ccc[ii][2] = bf ;
00081          NCLR = ii+1 ;
00082        } else {
00083          fprintf(stderr,
00084                  "%s = %s is not in form 'rgbi:val/val/val' with each val in [0,1].\n" ,
00085                  ename , eee ) ;
00086        }
00087      }
00088    }
00089 
00090    eee = getenv("AFNI_1DPLOT_THIK") ;  /* 27 Mar 2004 */
00091    if( eee != NULL ){
00092      rf = strtod(eee,NULL) ;
00093      if( rf >= 0.0 && rf <= 0.05 ) THIK = rf ;
00094      else
00095        fprintf(stderr,"AFNI_1DPLOT_THIK is not in range [0,0.05].\n") ;
00096    }
00097 }

float p10 float    x [static]
 

Definition at line 436 of file plot_ts.c.

Referenced by PLOT_scatterellipse(), plot_strip_init(), plot_ts_init(), plot_ts_mem(), and PLUTO_scatterplot().

00437 {
00438    double y ;
00439 
00440    if( x == 0.0 ) return 0.0 ;
00441    if( x <  0.0 ) x = -x ;
00442    y = floor(log10(x)+0.000001) ; y = pow( 10.0 , y ) ;
00443    return (float) y ;
00444 }

void plot_ts_addto MEM_topshell_data   mp,
int    nx,
float *    x,
int    ny,
float **    y
 

Definition at line 639 of file plot_ts.c.

References ccc, MEM_topshell_data::drawing, init_colors(), MEMPLOT_IDENT, MEMPLOT_NLINE, memplot_to_X11_sef(), mp, MEM_topshell_data::mp, NCLR, plotpak_line(), plotpak_set(), set_active_memplot(), set_color_memplot(), set_thick_memplot(), SY, THIK, MEM_topshell_data::userdata, MEM_topshell_data::valid, and WAY_BIG.

Referenced by AFNI_drive_addto_graph_xy(), and RT_registration_3D_realtime().

00641 {
00642    int ii , jj , yall , start ;
00643    float pbot,ptop , xobot,xotop,yobot,yotop , yll,yhh ;
00644    float xbot,xtop , ybot,ytop ;
00645    float * yy , * xx ;
00646    float * ud ;
00647 
00648    if( mp == NULL || mp->userdata == NULL || ! mp->valid ||
00649        nx <= 1    || ny == 0              || x == NULL   || y == NULL ) return ;
00650 
00651    init_colors() ;
00652 
00653    ud = (float *) mp->userdata ;
00654    xobot = ud[0] ; xotop = ud[1] ; yobot = ud[2] ; yotop = ud[3] ;
00655    xbot  = ud[4] ; xtop  = ud[5] ; ybot  = ud[6] ; ytop  = ud[7] ;
00656 
00657    yall = (ny > 0) ; if( !yall ) ny = -ny ;
00658 
00659    ii = set_active_memplot( MEMPLOT_IDENT(mp->mp) ) ;
00660    if( ii != 0 ) return ;
00661 
00662    start = MEMPLOT_NLINE(mp->mp) ;
00663    xx = x ;
00664 
00665    if( yall ){  /*-- all in one big happy box --*/
00666 
00667       plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
00668       set_thick_memplot( THIK ) ;
00669 
00670       /* plot data */
00671 
00672       for( jj=0 ; jj < ny ; jj++ ){
00673          set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00674 
00675          yy = y[jj] ;
00676          for( ii=1 ; ii < nx ; ii++ ){
00677             if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00678                 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG   )
00679 
00680                plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00681          }
00682       }
00683       set_thick_memplot( 0.0 ) ;
00684       set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00685 
00686    } else {  /*-- each in its own little sad box --*/
00687 
00688       float dyo = (yotop-yobot) / ( (1.0+SY) * ny - SY ) ;
00689 
00690       set_thick_memplot( THIK ) ;
00691 
00692       for( jj=ny-1 ; jj >= 0 ; jj-- ){
00693          yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00694          plotpak_set( xobot,xotop , yll,yhh , xbot,xtop , ybot,ytop , 1 ) ;
00695          set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00696 
00697          yy = y[jj] ;
00698          for( ii=1 ; ii < nx ; ii++ ){
00699             if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00700                 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG   )
00701 
00702                plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00703          }
00704       }
00705       set_thick_memplot( 0.0 ) ;
00706       set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00707    }
00708 
00709    memplot_to_X11_sef( XtDisplay(mp->drawing) , XtWindow(mp->drawing) ,
00710                        mp->mp , start,0,MEMPLOT_FREE_ASPECT ) ;
00711 
00712    return ;
00713 }

MEM_topshell_data* plot_ts_init Display *    dpy,
float    xbot,
float    xtop,
int    ny,
float    ybot,
float    ytop,
char *    lab_xxx,
char *    lab_yyy,
char *    lab_top,
char **    nam_yyy,
void_func   killfunc
 

Definition at line 448 of file plot_ts.c.

References ccc, create_memplot_surely(), dpy, free, get_active_memplot(), ilab, init_colors(), malloc, memplot_to_topshell(), mp, NCLR, p10(), plotpak_line(), plotpak_perimm(), plotpak_pwritf(), plotpak_set(), plotpak_setlin(), set_color_memplot(), set_thick_memplot(), STGOOD, SY, THIK, MEM_topshell_data::userdata, xpush, and ypush.

Referenced by AFNI_drive_open_graph_xy(), and RT_registration_3D_realtime().

00454 {
00455    int ii , jj , np , nnax,nnay , mmax,mmay , yall ;
00456    float pbot,ptop , xobot,xotop,yobot,yotop , yll,yhh ;
00457    char str[32] ;
00458    float * ud ;
00459    MEM_topshell_data * mp ;
00460 
00461    /*-- sanity check --*/
00462 
00463    if( dpy == NULL || ny == 0 || xbot >= xtop || ybot >= ytop ) return NULL ;
00464 
00465    init_colors() ;
00466 
00467    /*-- push range of x outwards --*/
00468 
00469    pbot = p10(xbot) ; ptop = p10(xtop) ; if( ptop < pbot ) ptop = pbot ;
00470    if( ptop != 0.0 && xpush ){
00471       np = (xtop-xbot) / ptop ;
00472       switch( np ){
00473          case 1:  ptop *= 0.1  ; break ;
00474          case 2:  ptop *= 0.2  ; break ;
00475          case 3:  ptop *= 0.25 ; break ;
00476          case 4:
00477          case 5:  ptop *= 0.5  ; break ;
00478       }
00479       xbot = floor( xbot/ptop ) * ptop ;
00480       xtop =  ceil( xtop/ptop ) * ptop ;
00481       nnax = floor( (xtop-xbot) / ptop + 0.5 ) ;
00482       mmax = (nnax < 3) ? 10
00483                         : (nnax < 6) ? 5 : 2 ;
00484    } else {
00485       nnax = 1 ; mmax = 10 ;
00486       ii = (int)rint(xtop-xbot) ;
00487       if( fabs(xtop-xbot-ii) < 0.01 && ii <= 200 ) mmax = ii ;
00488    }
00489 
00490    /*-- push range of y outwards --*/
00491 
00492    yall = (ny > 0) ; if( !yall ) ny = -ny ;
00493 
00494    pbot = p10(ybot) ; ptop = p10(ytop) ; if( ptop < pbot ) ptop = pbot ;
00495    if( ptop != 0.0 && ypush ){
00496       np = (ytop-ybot) / ptop ;
00497       switch( np ){
00498          case 1:  ptop *= 0.1  ; break ;
00499          case 2:  ptop *= 0.2  ; break ;
00500          case 3:  ptop *= 0.25 ; break ;
00501          case 4:
00502          case 5:  ptop *= 0.5  ; break ;
00503       }
00504       ybot = floor( ybot/ptop ) * ptop ;
00505       ytop =  ceil( ytop/ptop ) * ptop ;
00506       nnay = floor( (ytop-ybot) / ptop + 0.5 ) ;
00507       mmay = (nnay < 3) ? 10
00508                         : (nnay < 6) ? 5 : 2 ;
00509    } else {
00510       nnay = 1 ; mmay = 10 ;
00511    }
00512 
00513    /*-- setup to plot --*/
00514 
00515    create_memplot_surely( "Tsplot" , 1.3 ) ;
00516    set_thick_memplot( 0.5*THIK ) ;
00517 
00518    /*-- plot labels, if any --*/
00519 
00520    xobot = 0.15 ; xotop = 1.27 ;  /* set objective size of plot */
00521    yobot = 0.1  ; yotop = 0.95 ;
00522 
00523    if( STGOOD(lab_top) ){ yotop -= 0.02 ; yobot -= 0.01 ; }
00524    if( nam_yyy != NULL ){ xotop -= 0.16 ; xobot -= 0.02 ; }
00525 
00526    /* x-axis label? */
00527 
00528    set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00529    if( STGOOD(lab_xxx) )
00530       plotpak_pwritf( 0.5*(xobot+xotop) , yobot-0.06 , lab_xxx , 16 , 0 , 0 ) ;
00531 
00532    /* y-axis label? */
00533 
00534    set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00535    if( STGOOD(lab_yyy) )
00536       plotpak_pwritf( xobot-0.10 , 0.5*(yobot+yotop) , lab_yyy , 16 , 90 , 0 ) ;
00537 
00538    /* label at top? */
00539 
00540    set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00541    if( STGOOD(lab_top) )
00542       plotpak_pwritf( xobot+0.01 , yotop+0.01 , lab_top , 18 , 0 , -2 ) ;
00543 
00544    /*-- plot all on same vertical scale --*/
00545 
00546    ud = (float *) malloc( sizeof(float) * 8 ) ;
00547    ud[0] = xobot ; ud[1] = xotop ; ud[2] = yobot ; ud[3] = yotop ;
00548    ud[4] = xbot  ; ud[5] = xtop  ; ud[6] = ybot  ; ud[7] = ytop  ;
00549 
00550    if( yall ){
00551 
00552       /* do name labels at right? */
00553 
00554       if( nam_yyy != NULL ){
00555          float yv = yotop ; int sz ;
00556 
00557          for( jj=0 ; jj < ny ; jj++ ){
00558             if( STGOOD(nam_yyy[jj]) ){
00559                set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00560                set_thick_memplot( 2*THIK ) ;
00561                plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00562                set_thick_memplot( 0.5*THIK ) ;
00563                set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00564                sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00565                plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00566                yv -= 0.05 ;
00567             }
00568          }
00569       }
00570 
00571       /* plot axes */
00572 
00573       set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00574       plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
00575       plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)+2*(nnay>0)] ) ;
00576 
00577    } else {  /*-- plot each on separate vertical scale --*/
00578 
00579       float dyo = (yotop-yobot) / ( (1.0+SY) * ny - SY ) ;
00580 
00581       /* name labels at right? */
00582 
00583       if( nam_yyy != NULL ){
00584          float yv = yotop ; int sz ;
00585 
00586          for( jj=0 ; jj < ny ; jj++ ){
00587             yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00588             if( STGOOD(nam_yyy[jj]) ){
00589                set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00590                set_thick_memplot( 2*THIK ) ;
00591                yv = 0.7*yhh + 0.3*yll ;
00592                plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00593                set_thick_memplot( 0.5*THIK ) ;
00594                set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00595                sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00596                plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00597             }
00598          }
00599       }
00600 
00601       /* data each in its own box */
00602 
00603       nnay = 1 ;
00604       pbot = p10(ybot) ; ptop = p10(ytop) ;
00605       if( ptop > pbot && pbot > 0.0 ) ptop = pbot ;
00606       if( ptop != 0.0 ) mmay = floor( (ytop-ybot) / ptop + 0.5 ) ;
00607       else              mmay = 5 ;   /* shouldn't happen */
00608 
00609            if( mmay == 1 ) mmay = 5 ;
00610       else if( mmay == 2 ) mmay = 4 ;
00611       else if( mmay == 3 ) mmay = 6 ;
00612 
00613       for( jj=ny-1 ; jj >= 0 ; jj-- ){
00614          yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00615          plotpak_set( xobot,xotop , yll,yhh , xbot,xtop , ybot,ytop , 1 ) ;
00616          set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00617          plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)*(jj==0)+2*(nnay>0)] ) ;
00618          if( ybot < 0.0 && ytop > 0.0 ){
00619             plotpak_setlin(5) ;
00620             plotpak_line( xbot,0.0 , xtop,0.0 ) ;
00621             plotpak_setlin(1) ;
00622          }
00623       }
00624    }
00625 
00626    /*-- display --*/
00627 
00628    mp = memplot_to_topshell( dpy , get_active_memplot() , killfunc ) ;
00629    if( mp == NULL ){ free(ud) ; return NULL; }
00630    mp->userdata = ud ;
00631 
00632    /*-- exit, stage left --*/
00633 
00634    return mp ;
00635 }

void plot_ts_lab Display *    dpy,
int    nx,
float *    x,
int    ny,
float **    y,
char *    lab_xxx,
char *    lab_yyy,
char *    lab_top,
char **    nam_yyy,
void_func   killfunc
 

Definition at line 411 of file plot_ts.c.

References dpy, memplot_to_topshell(), mp, and plot_ts_mem().

Referenced by MCW_choose_CB(), PLUTO_histoplot(), RT_finish_dataset(), startup_timeout_CB(), T3D_check_outliers(), and VOLREG_main().

00415 {
00416    MEM_plotdata * mp ;
00417    int ymask = 0 ;
00418 
00419    if( dpy == NULL ) return ;
00420 
00421    if( ny < 0 ){ ymask = TSP_SEPARATE_YBOX ; ny = -ny ; }
00422 
00423    mp = plot_ts_mem( nx,x , ny,ymask,y , lab_xxx , lab_yyy , lab_top , nam_yyy ) ;
00424    if( mp != NULL )
00425      (void) memplot_to_topshell( dpy , mp , killfunc ) ;
00426 
00427    return ;
00428 }

MEM_plotdata* plot_ts_mem int    nx,
float *    x,
int    ny,
int    ymask,
float **    y,
char *    lab_xxx,
char *    lab_yyy,
char *    lab_top,
char **    nam_yyy
 

21 Apr 2005: check alternatives *

Definition at line 112 of file plot_ts.c.

References ccc, create_memplot_surely(), free, get_active_memplot(), ilab, init_colors(), malloc, mmaxx, mmayy, mp, NCLR, nnaxx, nnayy, p10(), plotpak_line(), plotpak_perimm(), plotpak_pwritf(), plotpak_set(), plotpak_setlin(), set_color_memplot(), set_thick_memplot(), STGOOD, SY, THIK, WAY_BIG, xpush, xxbot, xxtop, ypush, yybot, and yytop.

Referenced by ISQ_graymap_draw(), ISQ_rowgraph_draw(), main(), plot_ts_lab(), plot_ts_qqq(), and ROIPLOT_main().

00115 {
00116    int ii , jj , np , nnax,nnay , mmax,mmay ;
00117    float *xx , *yy ;
00118    float xbot,xtop , ybot,ytop , pbot,ptop , xobot,xotop,yobot,yotop ;
00119    char str[32] ;
00120    int yall , ysep ;
00121    float *ylo , *yhi , yll,yhh ;
00122    MEM_plotdata *mp ;
00123 
00124    /*-- sanity check --*/
00125 
00126    if( nx <= 1 || ny == 0 || y == NULL ) return NULL ;
00127 
00128    init_colors() ;
00129 
00130    /*-- make up an x-axis if none given --*/
00131 
00132    if( x == NULL ){
00133       xx = (float *) malloc( sizeof(float) * nx ) ;
00134       for( ii=0 ; ii < nx ; ii++ ) xx[ii] = ii ;
00135       xbot = 0 ; xtop = nx-1 ;
00136    } else {
00137       xx = x ;
00138       xbot = WAY_BIG ; xtop = -WAY_BIG ;
00139       for( ii=0 ; ii < nx ; ii++ ){
00140          if( xx[ii] < xbot && xx[ii] < WAY_BIG ) xbot = xx[ii] ;
00141          if( xx[ii] > xtop && xx[ii] < WAY_BIG ) xtop = xx[ii] ;
00142       }
00143       if( xbot >= xtop ) return NULL ;
00144    }
00145 
00146    /*-- push range of x outwards --*/
00147 
00148    pbot = p10(xbot) ; ptop = p10(xtop) ; if( ptop < pbot ) ptop = pbot ;
00149    if( nnaxx >= 0 ){
00150      nnax = nnaxx ; nnaxx = -1 ;
00151      mmax = mmaxx ;
00152      xbot = xxbot ;
00153      xtop = xxtop ;
00154    } else if( ptop != 0.0 && xpush ){
00155       np = (xtop-xbot) / ptop ;
00156       switch( np ){
00157          case 1:  ptop *= 0.1  ; break ;
00158          case 2:  ptop *= 0.2  ; break ;
00159          case 3:  ptop *= 0.25 ; break ;
00160          case 4:
00161          case 5:  ptop *= 0.5  ; break ;
00162       }
00163       xbot = floor( xbot/ptop ) * ptop ;
00164       xtop =  ceil( xtop/ptop ) * ptop ;
00165       nnax = floor( (xtop-xbot) / ptop + 0.5 ) ;
00166       mmax = (nnax < 3) ? 10
00167                         : (nnax < 6) ? 5 : 2 ;
00168    } else {
00169       nnax = 1 ; mmax = 10 ;
00170       ii = (int)rint(xtop-xbot) ;
00171       if( fabs(xtop-xbot-ii) < 0.01 && ii <= 200 ) mmax = ii ;
00172    }
00173 
00174    /*-- find range of y --*/
00175 
00176    yall = (ny == 1) || ((ymask & TSP_SEPARATE_YBOX) == 0) ;
00177    ysep = (ymask & TSP_SEPARATE_YSCALE) != 0 ;
00178                                                /* Nov 1998: find range of */
00179    ylo = (float *) malloc(sizeof(float)*ny) ;  /* each array separately. */
00180    yhi = (float *) malloc(sizeof(float)*ny) ;
00181 
00182    ybot = WAY_BIG ; ytop = -WAY_BIG ;
00183    for( jj=0 ; jj < ny ; jj++ ){
00184       yy  = y[jj] ; yll = WAY_BIG ; yhh = -WAY_BIG ;
00185       for( ii=0 ; ii < nx ; ii++ ){
00186          if( yy[ii] < yll && yy[ii] < WAY_BIG ) yll = yy[ii] ;
00187          if( yy[ii] > yhh && yy[ii] < WAY_BIG ) yhh = yy[ii] ;
00188       }
00189       ylo[jj] = yll ; yhi[jj] = yhh ;
00190       if( ybot > yll ) ybot = yll ;
00191       if( ytop < yhh ) ytop = yhh ;
00192       if( yll >= yhh ){                       /* shouldn't happen */
00193          yhh = yll + 0.05*fabs(yll) + 0.5 ;
00194          yll = yll - 0.05*fabs(yll) - 0.5 ;
00195          ylo[jj] = yll ; yhi[jj] = yhh ;
00196       }
00197    }
00198    if( ybot >= ytop ){                       /* shouldn't happen */
00199       ytop = ybot + 0.05*fabs(ybot) + 0.5 ;
00200       ybot = ybot - 0.05*fabs(ybot) - 0.5 ;
00201    }
00202 
00203    /* 30 Dec 1998 */
00204 
00205    if( !ysep ){
00206      for( jj=0 ; jj < ny ; jj++ ){ ylo[jj] = ybot ; yhi[jj] = ytop ; }
00207    }
00208 
00209    /*-- push range of y outwards --*/
00210 
00211    pbot = p10(ybot) ; ptop = p10(ytop) ; if( ptop < pbot ) ptop = pbot ;
00212    if( nnayy >= 0 ){
00213      nnay = nnayy ; nnayy = -1 ;
00214      mmay = mmayy ;
00215      ybot = yybot ;
00216      ytop = yytop ;
00217      for( jj=0 ; jj < ny ; jj++ ){ ylo[jj] = ybot ; yhi[jj] = ytop ; }
00218    } else if( ptop != 0.0 && ypush ){
00219       np = (ytop-ybot) / ptop ;
00220       switch( np ){
00221          case 1:  ptop *= 0.1  ; break ;
00222          case 2:  ptop *= 0.2  ; break ;
00223          case 3:  ptop *= 0.25 ; break ;
00224          case 4:
00225          case 5:  ptop *= 0.5  ; break ;
00226       }
00227       ybot = floor( ybot/ptop ) * ptop ;
00228       ytop =  ceil( ytop/ptop ) * ptop ;
00229       nnay = floor( (ytop-ybot) / ptop + 0.5 ) ;
00230       mmay = (nnay < 3) ? 10
00231                         : (nnay < 6) ? 5 : 2 ;
00232    } else {
00233       nnay = 1 ; mmay = 10 ;
00234    }
00235 
00236    for( jj=0 ; jj < ny ; jj++ ){
00237       pbot = p10(ylo[jj]) ; ptop = p10(yhi[jj]) ; if( ptop < pbot ) ptop = pbot ;
00238       if( ptop != 0.0 ){
00239          np = (yhi[jj]-ylo[jj]) / ptop ;
00240          switch( np ){
00241             case 1:  ptop *= 0.1  ; break ;
00242             case 2:  ptop *= 0.2  ; break ;
00243             case 3:  ptop *= 0.25 ; break ;
00244             case 4:
00245             case 5:  ptop *= 0.5  ; break ;
00246          }
00247          ylo[jj] = floor( ylo[jj]/ptop ) * ptop ;
00248          yhi[jj] =  ceil( yhi[jj]/ptop ) * ptop ;
00249       }
00250    }
00251 
00252    /*-- setup to plot --*/
00253 
00254    create_memplot_surely( "tsplot" , 1.3 ) ;
00255    set_thick_memplot( 0.2*THIK ) ;
00256 
00257    /*-- plot labels, if any --*/
00258 
00259    xobot = 0.15 ; xotop = 1.27 ;  /* set objective size of plot */
00260    yobot = 0.1  ; yotop = 0.95 ;
00261 
00262    if( STGOOD(lab_top) ){ yotop -= 0.02 ; yobot -= 0.01 ; }
00263    if( nam_yyy != NULL ){ xotop -= 0.16 ; xobot -= 0.02 ; }
00264 
00265    /* x-axis label? */
00266 
00267    set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00268    if( STGOOD(lab_xxx) )
00269       plotpak_pwritf( 0.5*(xobot+xotop) , yobot-0.06 , lab_xxx , 16 , 0 , 0 ) ;
00270 
00271    /* y-axis label? */
00272 
00273    set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00274    if( STGOOD(lab_yyy) )
00275       plotpak_pwritf( xobot-0.10 , 0.5*(yobot+yotop) , lab_yyy , 16 , 90 , 0 ) ;
00276 
00277    /* label at top? */
00278 
00279    set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00280    if( STGOOD(lab_top) )
00281       plotpak_pwritf( xobot+0.01 , yotop+0.01 , lab_top , 18 , 0 , -2 ) ;
00282 
00283    /*-- plot all on same vertical scale --*/
00284 
00285    if( yall ){
00286 
00287       /* do name labels at right? */
00288 
00289       if( nam_yyy != NULL ){
00290          float yv = yotop ; int sz ;
00291 
00292          for( jj=0 ; jj < ny ; jj++ ){
00293             if( STGOOD(nam_yyy[jj]) ){
00294                set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00295                set_thick_memplot( THIK ) ;
00296                plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00297                set_thick_memplot( 0.2*THIK ) ;
00298                set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00299                sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00300                plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00301                yv -= 0.05 ;
00302             }
00303          }
00304       }
00305 
00306       /* plot axes */
00307 
00308       set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00309       set_thick_memplot( 0.0 ) ;
00310       plotpak_set( xobot,xotop , yobot,yotop , xbot,xtop , ybot,ytop , 1 ) ;
00311       plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)+2*(nnay>0)] ) ;
00312 
00313       /* plot data */
00314 
00315       for( jj=0 ; jj < ny ; jj++ ){
00316          set_thick_memplot( THIK ) ;
00317          set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00318 
00319          yy = y[jj] ;
00320          for( ii=1 ; ii < nx ; ii++ ){
00321             if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00322                 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG   )
00323 
00324                plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00325          }
00326       }
00327       set_thick_memplot( 0.0 ) ;
00328       set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00329 
00330    } else {  /*-- plot each on separate vertical scale --*/
00331 
00332       float dyo = (yotop-yobot) / ( (1.0+SY) * ny - SY ) ;
00333 
00334       /* name labels at right? */
00335 
00336       if( nam_yyy != NULL ){
00337          float yv = yotop ; int sz ;
00338 
00339          for( jj=0 ; jj < ny ; jj++ ){
00340             yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00341             if( STGOOD(nam_yyy[jj]) ){
00342                set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00343                set_thick_memplot( 2*THIK ) ;
00344                yv = 0.7*yhh + 0.3*yll ;
00345                plotpak_line( xotop+0.008 , yv , xotop+0.042 , yv ) ;
00346                set_thick_memplot( 0.5*THIK ) ;
00347                set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00348                sz = (strlen(nam_yyy[jj]) <= 10) ? 12 : 10 ;
00349                plotpak_pwritf( xotop+0.048 , yv , nam_yyy[jj] , sz , 0 , -1 ) ;
00350             }
00351          }
00352       }
00353 
00354       /* data each in its own box */
00355 
00356       for( jj=ny-1 ; jj >= 0 ; jj-- ){
00357          yll = yobot + jj*(1.0+SY)*dyo ; yhh = yll + dyo ;
00358          plotpak_set( xobot,xotop , yll,yhh , xbot,xtop , ylo[jj],yhi[jj] , 1 ) ;
00359 
00360          if( nnay > 0 ){
00361            nnay = 1 ;
00362            pbot = p10(ylo[jj]) ; ptop = p10(yhi[jj]) ;
00363            if( ptop > pbot && pbot > 0.0 ) ptop = pbot ;
00364            if( ptop != 0.0 ) mmay = floor( (yhi[jj]-ylo[jj]) / ptop + 0.5 ) ;
00365            else              mmay = 5 ;   /* shouldn't happen */
00366 
00367                 if( mmay == 1 ) mmay = 5 ;
00368            else if( mmay == 2 ) mmay = 4 ;
00369            else if( mmay == 3 ) mmay = 6 ;
00370          }
00371 
00372          set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00373          plotpak_perimm( nnax,mmax , nnay,mmay , ilab[(nnax>0)*(jj==0)+2*(nnay>0)] ) ;
00374          if( ylo[jj] < 0.0 && yhi[jj] > 0.0 ){
00375             plotpak_setlin(5) ;
00376             plotpak_line( xbot,0.0 , xtop,0.0 ) ;
00377             plotpak_setlin(1) ;
00378          }
00379 
00380          set_color_memplot( ccc[jj%NCLR][0] , ccc[jj%NCLR][1] , ccc[jj%NCLR][2] ) ;
00381          set_thick_memplot( THIK ) ;
00382 
00383          yy = y[jj] ;
00384          for( ii=1 ; ii < nx ; ii++ ){
00385             if( xx[ii-1] < WAY_BIG && xx[ii] < WAY_BIG &&
00386                 yy[ii-1] < WAY_BIG && yy[ii] < WAY_BIG   )
00387 
00388                plotpak_line( xx[ii-1] , yy[ii-1] , xx[ii] , yy[ii] ) ;
00389          }
00390          set_thick_memplot( 0.0 ) ;
00391          set_color_memplot( 0.0 , 0.0 , 0.0 ) ;
00392       }
00393    }
00394 
00395    /*-- exit, stage left --*/
00396 
00397    if( xx != x ) free(xx) ;
00398    free(ylo) ; free(yhi) ;
00399 
00400    mp = get_active_memplot() ;
00401    return mp ;
00402 }

void plot_ts_xfix int    nax,
int    max,
float    xb,
float    xt
 

Definition at line 42 of file plot_ts.c.

References mmaxx, nnaxx, xxbot, and xxtop.

Referenced by main().

00043 {
00044   nnaxx = nax ; mmaxx = max ; xxbot = xb ; xxtop = xt ;
00045 }

void plot_ts_xypush int    a,
int    b
 

Definition at line 37 of file plot_ts.c.

References a, xpush, and ypush.

Referenced by main(), and RT_process_info().

00037 { xpush=a; ypush=b; }  /* 12 Mar 2003 */

void plot_ts_yfix int    nay,
int    may,
float    yb,
float    yt
 

Definition at line 47 of file plot_ts.c.

References mmayy, nnayy, yybot, and yytop.

Referenced by main().

00048 {
00049   nnayy = nay ; mmayy = may ; yybot = yb ; yytop = yt ;
00050 }

Variable Documentation

float ccc[NCLR_MAX][3] [static]
 

Initial value:

 {
  { 0.0 , 0.0 , 0.0 } ,
  { 0.9 , 0.0 , 0.0 } ,
  { 0.0 , 0.7 , 0.0 } ,
  { 0.0 , 0.0 , 0.9 } ,
}

Definition at line 17 of file plot_ts.c.

Referenced by init_colors(), plot_ts_addto(), plot_ts_init(), and plot_ts_mem().

int ilab[4] = { 0,2,3,1 } [static]
 

Definition at line 26 of file plot_ts.c.

Referenced by plot_ts_init(), and plot_ts_mem().

int mmaxx = -1 [static]
 

Definition at line 40 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_xfix().

int mmayy = -1 [static]
 

Definition at line 40 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_yfix().

int NCLR = 4 [static]
 

Definition at line 24 of file plot_ts.c.

Referenced by init_colors(), plot_ts_addto(), plot_ts_init(), and plot_ts_mem().

int nnaxx = -1 [static]
 

Definition at line 40 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_xfix().

int nnayy = -1 [static]
 

Definition at line 40 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_yfix().

float THIK = 0.003 [static]
 

Definition at line 32 of file plot_ts.c.

Referenced by init_colors(), plot_ts_addto(), plot_ts_init(), and plot_ts_mem().

int xpush = 1 [static]
 

Definition at line 35 of file plot_ts.c.

Referenced by plot_ts_init(), plot_ts_mem(), and plot_ts_xypush().

float xxbot [static]
 

Definition at line 39 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_xfix().

float xxtop [static]
 

Definition at line 39 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_xfix().

int ypush = 1 [static]
 

Definition at line 35 of file plot_ts.c.

Referenced by plot_ts_init(), plot_ts_mem(), and plot_ts_xypush().

float yybot [static]
 

Definition at line 39 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_yfix().

float yytop [static]
 

Definition at line 39 of file plot_ts.c.

Referenced by plot_ts_mem(), and plot_ts_yfix().

 

Powered by Plone

This site conforms to the following standards: