Skip to content

Commit 1d16134

Browse files
committed
feat: stash plot/ctor in plot/2d
1 parent 0dfee08 commit 1d16134

132 files changed

Lines changed: 10276 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/node_modules/@stdlib/plot/2d/README.md

Lines changed: 1465 additions & 0 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/plot/2d/docs/repl.txt

Lines changed: 452 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var normal = require( '@stdlib/random/array/normal' );
22+
var linspace = require( '@stdlib/array/linspace' );
23+
var Plot = require( './../lib' );
24+
25+
var opts = {
26+
'dtype': 'generic'
27+
};
28+
var x = linspace( 1, 100, 100, opts );
29+
var y1 = normal( 100, 50.0, 10.0, opts );
30+
var y2 = normal( 100, 20.0, 10.0, opts );
31+
32+
var plot = new Plot( [ x ], [ y1, y2 ], {
33+
'width': 600,
34+
'height': 480,
35+
'xScale': 'linear',
36+
'title': 'Hello World!'
37+
});
38+
39+
plot.render( onRender );
40+
41+
function onRender( error, result ) {
42+
if ( error ) {
43+
throw error;
44+
}
45+
console.log( result );
46+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var randn = require( '@stdlib/random/base/box-muller' );
5+
var Float32Array = require( '@stdlib/array/float32' );
6+
var Float64Array = require( '@stdlib/array/float64' );
7+
var Plot = require( './../lib' );
8+
9+
var y1;
10+
var y2;
11+
var x;
12+
var i;
13+
14+
// Create some data...
15+
x = new Float64Array( 100 );
16+
y1 = new Float64Array( x.length );
17+
y2 = new Float32Array( x.length );
18+
for ( i = 0; i < x.length; i++ ) {
19+
x[ i ] = i;
20+
y1[ i ] = 50.0 + (10.0*randn());
21+
y2[ i ] = 10.0 + (5.0*randn());
22+
}
23+
24+
// Create a new plot:
25+
var plot = new Plot( [ x, x ], [ y1, y2 ] );
26+
plot.width = 600;
27+
plot.height = 480;
28+
plot.symbols = [ 'open-circle', 'closed-circle' ];
29+
plot.symbolsSize = 6;
30+
31+
// View the plot in a window:
32+
plot.view( 'window' );
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var randn = require( '@stdlib/random/base/box-muller' );
5+
var Float64Array = require( '@stdlib/array/float64' );
6+
var Plot = require( './../lib' );
7+
8+
var plot;
9+
var opts;
10+
var y1;
11+
var y2;
12+
var y3;
13+
var y4;
14+
var x;
15+
var i;
16+
17+
// Create some data...
18+
x = new Float64Array( 100 );
19+
y1 = new Float64Array( x.length );
20+
y2 = new Float64Array( x.length );
21+
y3 = new Float64Array( x.length );
22+
y4 = new Float64Array( x.length );
23+
for ( i = 0; i < x.length; i++ ) {
24+
x[ i ] = i;
25+
y1[ i ] = 10.0 + (5.0*randn());
26+
y2[ i ] = 25.0 + (7.25*randn());
27+
y3[ i ] = 50.0 + (10.0*randn());
28+
y4[ i ] = 75.0 + (2.5*randn());
29+
}
30+
31+
// Set the plot options:
32+
opts = {
33+
'width': 600,
34+
'height': 480,
35+
'colors': '#000',
36+
'lineOpacity': 0.5,
37+
'lineWidth': 1,
38+
'lineStyle': [
39+
'-', // solid
40+
'--', // dashes
41+
':', // dotted
42+
'-.' // dash-dot
43+
],
44+
'viewer': 'window'
45+
};
46+
47+
// Create a new plot:
48+
plot = new Plot( [ x, x, x, x ], [ y1, y2, y3, y4 ], opts );
49+
50+
// View the plot:
51+
plot.view();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var randn = require( '@stdlib/random/base/box-muller' );
5+
var Float64Array = require( '@stdlib/array/float64' );
6+
var Float32Array = require( '@stdlib/array/float32' );
7+
var Plot = require( './../lib' );
8+
9+
var plot;
10+
var y1;
11+
var y2;
12+
var x;
13+
var i;
14+
15+
// Create some data...
16+
x = new Float64Array( 100 );
17+
y1 = new Float64Array( x.length );
18+
y2 = new Float32Array( x.length );
19+
for ( i = 0; i < x.length; i++ ) {
20+
x[ i ] = i;
21+
y1[ i ] = 50.0 + (10.0*randn());
22+
y2[ i ] = 10.0 + (5.0*randn());
23+
}
24+
25+
// Create a new plot:
26+
plot = new Plot( [ x, x ], [ y1, y2 ] );
27+
plot.width = 600;
28+
plot.height = 480;
29+
30+
// View the plot in a window:
31+
plot.view( 'window' );
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var randn = require( '@stdlib/random/base/box-muller' );
5+
var Float64Array = require( '@stdlib/array/float64' );
6+
var Float32Array = require( '@stdlib/array/float32' );
7+
var Plot = require( './../lib' );
8+
9+
var plot;
10+
var opts;
11+
var x1;
12+
var x2;
13+
var y1;
14+
var y2;
15+
var i;
16+
17+
// Create some data...
18+
x1 = new Float64Array( 1000 );
19+
x2 = new Float64Array( x1.length );
20+
y1 = new Float64Array( x1.length );
21+
y2 = new Float32Array( x1.length );
22+
for ( i = 0; i < x1.length; i++ ) {
23+
x1[ i ] = 30.0 + (7.5*randn());
24+
x2[ i ] = 40.0 + (12.5*randn());
25+
y1[ i ] = 50.0 + (10.0*randn());
26+
y2[ i ] = 30.0 + (5.0*randn());
27+
}
28+
29+
// Define the plot options:
30+
opts = {
31+
'width': 600,
32+
'height': 480,
33+
'xMin': 0.0,
34+
'xMax': 100.0,
35+
'yMin': 0.0,
36+
'yMax': 100.0,
37+
'lineStyle': 'none',
38+
'symbols': 'closed-circle',
39+
'symbolsSize': 6,
40+
'symbolsOpacity': 0.2
41+
};
42+
43+
// Create a new plot:
44+
plot = new Plot( [ x1, x2 ], [ y1, y2 ], opts );
45+
46+
// View the plot in a window:
47+
plot.view( 'window' );
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var randn = require( '@stdlib/random/base/box-muller' );
5+
var Float64Array = require( '@stdlib/array/float64' );
6+
var Float32Array = require( '@stdlib/array/float32' );
7+
var Plot = require( './../lib' );
8+
9+
var plot;
10+
var opts;
11+
var x1;
12+
var x2;
13+
var y1;
14+
var y2;
15+
var i;
16+
17+
// Create some data...
18+
x1 = new Float64Array( 1000 );
19+
x2 = new Float64Array( x1.length );
20+
y1 = new Float64Array( x1.length );
21+
y2 = new Float32Array( x1.length );
22+
for ( i = 0; i < x1.length; i++ ) {
23+
x1[ i ] = 30.0 + (7.5*randn());
24+
x2[ i ] = 40.0 + (12.5*randn());
25+
y1[ i ] = 50.0 + (10.0*randn());
26+
y2[ i ] = 30.0 + (5.0*randn());
27+
}
28+
29+
// Define the plot options:
30+
opts = {
31+
'width': 600,
32+
'height': 480,
33+
'xMin': 0.0,
34+
'xMax': 100.0,
35+
'yMin': 0.0,
36+
'yMax': 100.0,
37+
'lineStyle': 'none',
38+
'symbols': 'closed-circle',
39+
'symbolsSize': 6,
40+
'symbolsOpacity': 0.2,
41+
'xRug': true,
42+
'yRug': true,
43+
'xRugOrient': 'top',
44+
'yRugOrient': 'right'
45+
};
46+
47+
// Create a new plot:
48+
plot = new Plot( [ x1, x2 ], [ y1, y2 ], opts );
49+
50+
// View the plot in a window:
51+
plot.view( 'window' );
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var randn = require( '@stdlib/random/base/box-muller' );
5+
var Float64Array = require( '@stdlib/array/float64' );
6+
var now = require( '@stdlib/time/now' );
7+
var Plot = require( './../lib' );
8+
9+
var t;
10+
var x;
11+
var y;
12+
var i;
13+
14+
// Create some data...
15+
t = now() * 1000;
16+
x = new Float64Array( 100 );
17+
y = new Float64Array( x.length );
18+
for ( i = 0; i < x.length; i++ ) {
19+
x[ i ] = t + (i*360000);
20+
y[ i ] = 50.0 + (10.0*randn());
21+
}
22+
23+
// Create a new plot:
24+
var plot = new Plot( [ x ], [ y ] );
25+
plot.width = 600;
26+
plot.height = 480;
27+
plot.xScale = 'time';
28+
plot.xTickFormat = '%H:%M';
29+
30+
// View the plot in a browser:
31+
plot.view( 'browser' );

0 commit comments

Comments
 (0)