Function:s2sch

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:27, 23 November 2007
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 26: Line 26:
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
 +#include <time.h>
#include "s2plot.h" #include "s2plot.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
- float x = 0.0; /* Text location */+ float x = 0.0; /* Text location */
float y = 0.0; float y = 0.0;
- float z = 0.0; + float z = 0.0;
- int N = 4; /* Number of strings */+ int N = 4; /* Number of strings */
- int i; /* Loop variable */+ int i; /* Loop variable */
- float height; /* Height of text */+ float height; /* Height of text */
- char string[32]; /* String of text */+ char string[32]; /* String of text */
- s2opend("/?",argc, argv); /* Open the display */+ srand48((long)time(NULL)); /* Seed random numbers */
- s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */+ s2opend("/?",argc, argv); /* Open the display */
- s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */+ s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
 + s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
for (i=0;i<N;i++) { for (i=0;i<N;i++) {
- s2sci((i%15)+1); /* Set the colour */+ s2sci((i%15)+1); /* Set the colour */
- height = (i+1)*0.3; + height = (i+1)*0.3;
- sprintf(string,"Height = %.1f\n",height); /* Create the string */+ sprintf(string,"Height = %.1f\n",height); /* Create the string */
- x = drand48()*1.6 - 0.8; /* Random text location */+ x = drand48()*1.6 - 0.8; /* Random text location */
y = drand48()*1.6 - 0.8; y = drand48()*1.6 - 0.8;
z = drand48()*1.6 - 0.8; z = drand48()*1.6 - 0.8;
- s2sch(height); /* Set text height */+ s2sch(height); /* Set text height */
- s2textxy(x,y,z,string); /* Write some text in x-y plane */+ s2textxy(x,y,z,string); /* Write some text in x-y plane */
} }
- s2show(1); /* Open the s2plot window */+ s2show(1); /* Open the s2plot window */
- + 
return 1; return 1;
} }
 +
</pre></code> </pre></code>
[[S2PLOT:Function List | Back]] to S2PLOT function list. [[S2PLOT:Function List | Back]] to S2PLOT function list.
__NOTOC__ __NOTOC__
__NOEDITSECTION__ __NOEDITSECTION__

Current revision

s2sch

Set the character height in "arbitrary" units.

Prototype

void s2sch(float size);

Description

Set the character height in "arbitrary" units. The default character size is 1.0, corresponding to a character about 15 pixels in size. Changing the character height also changes the scale of tick marks and symbols.

See Also

s2qch Query the character height.
s2slw Set the linewidth in pixels.

PGPLOT Equivalent

PGSCH

Code Example

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"

int main(int argc, char *argv[])
{
   float x = 0.0;                               /* Text location */
   float y = 0.0;
   float z = 0.0;
   int N = 4;                                   /* Number of strings */
   int i;                                       /* Loop variable */
   float height;                                /* Height of text */
   char string[32];                             /* String of text */

   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/?",argc, argv);                    /* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */

   for (i=0;i<N;i++) {
      s2sci((i%15)+1);                          /* Set the colour */
      height = (i+1)*0.3;
      sprintf(string,"Height = %.1f\n",height); /* Create the string */
      x = drand48()*1.6 - 0.8;                  /* Random text location */
      y = drand48()*1.6 - 0.8;
      z = drand48()*1.6 - 0.8;
      s2sch(height);                    /* Set text height */
      s2textxy(x,y,z,string);                   /* Write some text in x-y plane */
   }

   s2show(1);                                   /* Open the s2plot window */

   return 1;
}

Back to S2PLOT function list.


Personal tools