GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — papiplot/papiplot/test/example.c at master · orcc/papiplot

Expand file tree

/

example.c

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
157 lines (126 loc) · 3.61 KB
/

example.c

Copy path

File metadata and controls

157 lines (126 loc) · 3.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Examples of gnuplot_i.c usage
*/
#include <stdio.h>
#include <stdlib.h>
#include "../src/gnuplot_i.h"
#define SLEEP_LGTH 2
#define NPOINTS 50
int example(void)
{
gnuplot_ctrl * h1,
* h2,
* h3,
* h4 ;
double x[NPOINTS] ;
double y[NPOINTS] ;
int i ;
/*
* Initialize the gnuplot handle
*/
printf("*** example of gnuplot control through C ***\n") ;
h1 = gnuplot_init() ;
/*
* Slopes
*/
gnuplot_setstyle(h1, "lines") ;
printf("*** plotting slopes\n") ;
printf("y = x\n") ;
gnuplot_plot_slope(h1, 1.0, 0.0, "unity slope") ;
sleep(SLEEP_LGTH) ;
printf("y = 2*x\n") ;
gnuplot_plot_slope(h1, 2.0, 0.0, "y=2x") ;
sleep(SLEEP_LGTH) ;
printf("y = -x\n") ;
gnuplot_plot_slope(h1, -1.0, 0.0, "y=-x") ;
sleep(SLEEP_LGTH) ;
/*
* Equations
*/
gnuplot_resetplot(h1) ;
printf("\n\n") ;
printf("*** various equations\n") ;
printf("y = sin(x)\n") ;
gnuplot_plot_equation(h1, "sin(x)", "sine") ;
sleep(SLEEP_LGTH) ;
printf("y = log(x)\n") ;
gnuplot_plot_equation(h1, "log(x)", "logarithm") ;
sleep(SLEEP_LGTH) ;
printf("y = sin(x)*cos(2*x)\n") ;
gnuplot_plot_equation(h1, "sin(x)*cos(2*x)", "sine product") ;
sleep(SLEEP_LGTH) ;
/*
* Styles
*/
gnuplot_resetplot(h1) ;
printf("\n\n") ;
printf("*** showing styles\n") ;
printf("sine in points\n") ;
gnuplot_setstyle(h1, "points") ;
gnuplot_plot_equation(h1, "sin(x)", "sine") ;
sleep(SLEEP_LGTH) ;
printf("sine in impulses\n") ;
gnuplot_setstyle(h1, "impulses") ;
gnuplot_plot_equation(h1, "sin(x)", "sine") ;
sleep(SLEEP_LGTH) ;
printf("sine in steps\n") ;
gnuplot_setstyle(h1, "steps") ;
gnuplot_plot_equation(h1, "sin(x)", "sine") ;
sleep(SLEEP_LGTH) ;
/*
* User defined 1d and 2d point sets
*/
gnuplot_resetplot(h1) ;
gnuplot_setstyle(h1, "impulses") ;
printf("\n\n") ;
printf("*** user-defined lists of doubles\n") ;
for (i=0 ; i<NPOINTS ; i++) {
x[i] = (double)i*i ;
}
gnuplot_plot_x(h1, x, NPOINTS, "user-defined doubles") ;
sleep(SLEEP_LGTH) ;
printf("*** user-defined lists of points\n");
for (i=0 ; i<NPOINTS ; i++) {
x[i] = (double)i ;
y[i] = (double)i * (double)i ;
}
gnuplot_resetplot(h1) ;
gnuplot_setstyle(h1, "points") ;
gnuplot_plot_xy(h1, x, y, NPOINTS, "user-defined points") ;
sleep(SLEEP_LGTH) ;
/*
* Multiple output screens
*/
printf("\n\n") ;
printf("*** multiple output windows\n") ;
gnuplot_resetplot(h1) ;
gnuplot_setstyle(h1, "lines") ;
h2 = gnuplot_init() ;
gnuplot_setstyle(h2, "lines") ;
h3 = gnuplot_init() ;
gnuplot_setstyle(h3, "lines") ;
h4 = gnuplot_init() ;
gnuplot_setstyle(h4, "lines") ;
printf("window 1: sin(x)\n") ;
gnuplot_plot_equation(h1, "sin(x)", "sin(x)") ;
sleep(SLEEP_LGTH) ;
printf("window 2: x*sin(x)\n") ;
gnuplot_plot_equation(h2, "x*sin(x)", "x*sin(x)") ;
sleep(SLEEP_LGTH) ;
printf("window 3: log(x)/x\n") ;
gnuplot_plot_equation(h3, "log(x)/x", "log(x)/x");
sleep(SLEEP_LGTH) ;
printf("window 4: sin(x)/x\n") ;
gnuplot_plot_equation(h4, "sin(x)/x", "sin(x)/x") ;
sleep(SLEEP_LGTH) ;
/*
* close gnuplot handles
*/
printf("\n\n") ;
printf("*** end of gnuplot example\n") ;
gnuplot_close(h1) ;
gnuplot_close(h2) ;
gnuplot_close(h3) ;
gnuplot_close(h4) ;
return 0 ;
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.