Function:s2sch
From S2PLOT
(Difference between revisions)
| Revision as of 08:39, 27 October 2007 60.230.35.85 (Talk) ← Previous diff |
Current revision S2plot admin (Talk | contribs) |
||
| Line 15: | Line 15: | ||
| == See Also == | == See Also == | ||
| <table> | <table> | ||
| + | <tr><td>[[Function:s2qch | s2qch ]]</td><td>Query the character height. </td></tr> | ||
| <tr><td>[[Function:s2slw | s2slw ]]</td><td>Set the linewidth in pixels. </td></tr> | <tr><td>[[Function:s2slw | s2slw ]]</td><td>Set the linewidth in pixels. </td></tr> | ||
| </table> | </table> | ||
| Line 25: | 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
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.
