### Installation Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=code Instructions on how to install the nodeplotlib package using npm or yarn. ```APIDOC ## Installation ``` npm install nodeplotlib # or yarn add nodeplotlib ``` ``` -------------------------------- ### Installation Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=dependencies Install the nodeplotlib package using npm or yarn. ```APIDOC ## Installation ``` npm install nodeplotlib # or yarn add nodeplotlib ``` ``` -------------------------------- ### Install NodePlotLib via Yarn Source: https://www.npmjs.com/package/nodeplotlib/v/0.6.2?activeTab=readme Alternative installation command for nodeplotlib using Yarn. ```bash yarn add nodeplotlib ``` -------------------------------- ### Install NodePlotLib Source: https://www.npmjs.com/package/nodeplotlib/v/0.0.5?activeTab=code Install the nodeplotlib package using npm or yarn. ```bash npm install nodeplotlib # or yarn add nodeplotlib ``` -------------------------------- ### Basic Plotting with TensorFlow.js Source: https://www.npmjs.com/package/nodeplotlib/v/0.0.5 This example demonstrates how to use nodeplotlib to plot data generated with TensorFlow.js. Ensure TensorFlow.js is installed. ```javascript import { sequential, layers, tensor2d } from '@tensorflow/tfjs'; import '@tensorflow/tfjs-node-gpu'; // Just import plot import { plot } from 'nodeplotlib'; const model = sequential(); model.add(layers.dense({units: 1, inputShape: [1], name: 'mytensor'})); model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); const tensorX = [1, 2, 3, 4]; const tensorY = [1, 3, 5, 7]; const xs = tensor2d(tensorX, [4, 1]); const ys = tensor2d(tensorY, [4, 1]); // Spawn a plot in your browser plot([{ x: tensorX, y: tensorY, type: 'line' }]); ``` -------------------------------- ### Plot Data with TensorFlow.js Source: https://www.npmjs.com/package/nodeplotlib/v/0.0.5?activeTab=code This example demonstrates plotting data generated with TensorFlow.js. Ensure TensorFlow.js is installed and imported. ```typescript import { sequential, layers, tensor2d } from '@tensorflow/tfjs'; import '@tensorflow/tfjs-node-gpu'; // Just import plot import { plot } from 'nodeplotlib'; const model = sequential(); model.add(layers.dense({units: 1, inputShape: [1], name: 'mytensor'})); model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); const tensorX = [1, 2, 3, 4]; const tensorY = [1, 3, 5, 7]; const xs = tensor2d(tensorX, [4, 1]); const ys = tensor2d(tensorY, [4, 1]); // Spawn a plot in your browser plot([{ x: tensorX, y: tensorY, type: 'line' }]); ``` -------------------------------- ### Basic Usage Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=code A simple example demonstrating how to import and use the `plot` function with basic data. ```APIDOC ## Usage ### Overview Use with TypeScript/JavaScript: ``` import { plot } from 'nodeplotlib'; const data = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'line'}]; plot(data); ``` If ES5 use `require()` instead of `import`. ``` -------------------------------- ### Creating a Bar Chart Source: https://www.npmjs.com/package/nodeplotlib/v/0.4.0?activeTab=code Example of creating a bar chart with x and y data. ```javascript const trace = {x: [1, 2], y: [1, 2], type: 'bar'}; plot([trace]); ``` -------------------------------- ### Plotting Examples Source: https://www.npmjs.com/package/nodeplotlib/v/0.7.4?activeTab=versions Examples demonstrating how to create various types of plots using NodePlotLib, including line plots, bar charts, and 3D plots. ```APIDOC ## Plotting Examples ### Line Plots ```javascript const { plot, Plot } = require('nodeplotlib'); const trace1 = {x: [1, 2], y: [1, 2], type: 'scatter'}; const trace2 = {x: [3, 4], y: [9, 16], type: 'scatter'}; plot([trace1, trace2]); ``` ### Bar Charts ```javascript const { plot, Plot } = require('nodeplotlib'); const trace = {x: [1, 2], y: [1, 2], type: 'bar'}; plot([trace]); ``` ### 3D Line Plots ```javascript const { plot, Plot } = require('nodeplotlib'); const trace = {x: [9, 8, 5, 1], y: [1, 2, 4, 8], z: [11, 8, 15, 3], type: 'scatter3d'}; plot([trace]); ``` ### 3D Surface Plots ```javascript const { plot, Plot } = require('nodeplotlib'); const trace = {colorscale: 'Viridis', z: [[3, 5, 7, 9], [21, 13, 8, 5]]}; plot([trace]); ``` ### Radial Plots with Layout ```javascript const { plot, stack, clear, Plot, Layout } = require('nodeplotlib'); const data = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout = { polar: { radialaxis: { visible: true, range: [0, 50] } } }; plot(data, layout); ``` ``` -------------------------------- ### Install NodePlotLib (Specific Version) Source: https://www.npmjs.com/package/nodeplotlib/v/0.6.5 Installs a specific version of the nodeplotlib package using npm. ```bash npm i nodeplotlib@0.6.5 ``` -------------------------------- ### Plotting with Layout Source: https://www.npmjs.com/package/nodeplotlib/v/0.5.2 Demonstrates how to customize plots using the `layout` parameter, providing examples for radial plots. ```APIDOC ## plot(data?: Plot[], layout?: Layout): void ### Description Plots data with customizable layout options. The `layout` parameter accepts a partial `Layout` object from plotly.js for styling. ### Method ```javascript plot(data?: Plot[], layout?: Layout): void; ``` ### Parameters - **data** (Plot[]) - Optional - An array of Plot objects to be plotted. - **layout** (Layout) - Optional - A partial `Layout` object from plotly.js for styling the plot (e.g., title, axis labels, polar settings). ### Request Example (Radial Plot) ```javascript import { plot, Plot, Layout } from 'nodeplotlib'; const data: Plot[] = [ { type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' } ]; const layout: Partial = { polar: { radialaxis: { visible: true, range: [0, 50] } } }; plot(data, layout); ``` ``` -------------------------------- ### Plotting with Layout Options Source: https://www.npmjs.com/package/nodeplotlib?activeTab=code Example of creating a radial plot and customizing its appearance using the `layout` parameter. ```APIDOC import { plot, Plot, Layout } from 'nodeplotlib'; const data: Plot[] = [ { type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A', 'B', 'C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B', }, ]; const layout: Layout = { polar: { radialaxis: { visible: true, range: [0, 50], }, }, }; plot(data, layout); ``` -------------------------------- ### Plotting with Layout Source: https://www.npmjs.com/package/nodeplotlib/v/0.5.0?activeTab=code Demonstrates how to customize plot appearance using the `layout` parameter, including examples for radial plots. ```APIDOC ## plot(data?: Plot[], layout?: Layout, cb?: Function): void ### Description Plots data with customizable layout options. The `layout` parameter accepts a partial `Layout` object from plotly.js, allowing for extensive styling. ### Parameters * **data** (Plot[]) - Optional - Plot data. * **layout** (Layout) - Optional - Plotly `Layout` object for styling (e.g., titles, axis labels, polar configurations). * **cb** (Function) - Optional - Callback function. ### Request Example (Radial Plot) ```javascript import { plot, Plot, Layout } from 'nodeplotlib'; const data: Plot[] = [ { type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' } ]; const layout: Partial = { polar: { radialaxis: { visible: true, range: [0, 50] } } }; plot(data, layout); ``` ``` -------------------------------- ### Creating a Line Plot Source: https://www.npmjs.com/package/nodeplotlib/v/0.4.0?activeTab=code Example of creating a line plot by defining two trace objects with x and y data. ```javascript const trace1 = {x: [1, 2], y: [1, 2], type: 'scatter'}; const trace2 = {x: [3, 4], y: [9, 16], type: 'scatter'}; plot([trace1, trace2]); ``` -------------------------------- ### Layout Customization Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=code Example showing how to customize plot appearance using the `layout` parameter, including radial plots. ```APIDOC ## Layout In order to style the plot, one is able to pass in the `layout` parameter. With it one is able to define styles like _title_ , _axis labels_ , _subplots_ and many more. ``` const data = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout = [ polar: { radialaxis: { visible: true, range: [0, 50] } } ]; plot(data, layout); ``` ``` -------------------------------- ### Layout Parameter Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=code Demonstrates how to use the `layout` parameter to style plots, including examples for titles, axis labels, and subplots. ```APIDOC ## Layout In order to style the plot, one is able to pass in the `layout` parameter. With it one is able to define styles like _title_ , _axis labels_ , _subplots_ and many more. Plotly.js provides a nice example for radial plots. Just pass in the plotly.js data to the `plot()` function and spawn radial plots. ``` const data = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout = [ polar: { radialaxis: { visible: true, range: [0, 50] } } ]; plot(data, layout); ``` ``` -------------------------------- ### Creating a Radial Plot with Layout Styling Source: https://www.npmjs.com/package/nodeplotlib/v/0.4.0?activeTab=code Example of creating a scatterpolar plot and applying custom layout options, such as radial axis visibility and range. ```typescript const data: Plot[] = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout: Layout = [ polar: { radialaxis: { visible: true, range: [0, 50] } } ]; plot(data, layout); ``` -------------------------------- ### Stacking and Plotting Multiple Charts Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=dependents Shows how to use `stack` to queue multiple plots and `plot` to render them all at once. ```APIDOC ## stack(data?: Partial[], layout?: Partial): void ### Description Stacks plot data to be rendered later. Useful for creating multiple charts on the same page. ### Parameters * **data** (Partial[]): Optional. An array of Plotly.js PlotData objects to stack. * **layout** (Partial): Optional. Plotly.js layout object for styling the stacked plots. ## plot() ### Description Plots all stacked plots and any plot data provided as an argument. Clears the temporary container afterwards. ### Request Example ```javascript import { plot, stack } from 'nodeplotlib'; import { PlotData } from 'plotly.js'; const data: Partial[] = [{ x: [ 1, 3, 4, 6, 7], y: [ 2, 4, 6, 8, 9], type: 'scatter' }]; stack(data); stack(data); stack(data); plot(); ``` ``` -------------------------------- ### Stacking and Plotting Multiple Charts Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=dependencies Illustrates how to use the `stack` function to queue multiple plots and then display them all at once using `plot`. ```APIDOC ## stack(data?: Partial[], layout?: Partial): void ### Description Stacks plot data to be displayed later. Multiple calls to `stack` will queue multiple charts. ### Method stack ### Parameters - **data** (Partial[]): Optional array of plot data objects. - **layout** (Partial): Optional layout object for styling the plot. ### Request Example ```javascript import { plot, stack } from 'nodeplotlib'; import { PlotData } from 'plotly.js'; const data: Partial[] = [{ x: [ 1, 3, 4, 6, 7], y: [ 2, 4, 6, 8, 9], type: 'scatter' }]; stack(data); stack(data); stack(data); plot(); // Plots all stacked plots ``` ``` -------------------------------- ### Basic Plotting Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=dependents Demonstrates the basic usage of the `plot` function to create a line chart. ```APIDOC ## plot(data?: Partial[], layout?: Partial, cb?: Function): void ### Description Spawns a plot to the browser with the given plot data. If no data is provided, it plots all stacked plot data. ### Parameters * **data** (Partial[]): Optional. An array of Plotly.js PlotData objects to plot. * **layout** (Partial): Optional. Plotly.js layout object for styling the plot. * **cb** (Function): Optional. A callback function to be executed after plotting. ### Request Example ```javascript import { plot } from 'nodeplotlib'; const data = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'line'}]; plot(data); ``` ``` -------------------------------- ### Basic Plotting Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=dependencies Demonstrates how to create a simple line plot using the `plot` function with provided data. ```APIDOC ## plot(data?: Partial[], layout?: Partial, cb?: Function): void ### Description Spawns a plot to the browser with the given plot data. If no plot data is provided, it plots all stacked plot data. ### Method plot ### Parameters - **data** (Partial[]): Optional array of plot data objects. - **layout** (Partial): Optional layout object for styling the plot. - **cb** (Function): Optional callback function. ### Request Example ```javascript import { plot } from 'nodeplotlib'; const data = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'line'}]; plot(data); ``` ``` -------------------------------- ### Real-time Plotting with RxJS Source: https://www.npmjs.com/package/nodeplotlib?activeTab=code Shows how to create a real-time plotting stream using RxJS, where data is updated at regular intervals. ```APIDOC import { plot, Plot } from 'nodeplotlib'; import { interval, map, Observable } from 'rxjs'; const stream$: Observable = interval(100).pipe( map(createSinusPlotFromNumber) ); function createSinusPlotFromNumber(num: number): Plot[] { const data: Plot[] = [ { x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], y: Array(10) .fill(0) .map((_, i) => Math.sin(num + i)), type: 'scatter', }, ]; return data; } plot(stream$); ``` -------------------------------- ### Basic Plotting Source: https://www.npmjs.com/package/nodeplotlib?activeTab=readme Demonstrates how to create a simple scatter plot using the `plot` function with basic data. ```APIDOC ## Basic Plotting ### Description This example shows how to create a basic scatter plot. ### Usage ```typescript import { plot, Plot } from 'nodeplotlib'; const data: Plot[] = [ { x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'scatter', }, ]; plot(data); ``` ``` -------------------------------- ### Real-time Plotting with Streams Source: https://www.npmjs.com/package/nodeplotlib?activeTab=readme Illustrates how to create a real-time plotting stream using RxJS, updating the plot based on an interval and a mapping function. ```APIDOC ## Real-time Plotting with Streams ### Description This example demonstrates creating a real-time plot using RxJS streams. Data is generated at intervals and mapped to a plot. ### Usage ```typescript import { plot, Plot } from 'nodeplotlib'; import { interval, map, Observable } from 'rxjs'; const stream$: Observable = interval(100).pipe( map(createSinusPlotFromNumber) ); function createSinusPlotFromNumber(num: number): Plot[] { const data: Plot[] = [ { x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], y: Array(10) .fill(0) .map((_, i) => Math.sin(num + i)), type: 'scatter', }, ]; return data; } plot(stream$); ``` ``` -------------------------------- ### Radial Plot with Layout Customization Source: https://www.npmjs.com/package/nodeplotlib/v/0.7.7 Create a radial plot (polar chart) and customize its appearance using the 'layout' parameter. This example sets the radial axis range. ```typescript import { plot, Plot, Layout } from 'nodeplotlib'; const data: Plot[] = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout: Layout = { polar: { radialaxis: { visible: true, range: [0, 50] } } }; plot(data, layout); ``` -------------------------------- ### Plotting with Layout Options Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=versions Demonstrates how to customize plots by providing a `layout` object to the `plot` function. ```APIDOC ## plot(data, layout) ### Description Spawns a plot to the browser with the given plot data and layout options for styling. ### Method plot ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (Partial[]) - An array of Plotly.js PlotData objects to plot. - **layout** (Partial) - Plotly.js layout object for styling. ### Request Example ```javascript const data = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout = { polar: { radialaxis: { visible: true, range: [0, 50] } } }; plot(data, layout); ``` ### Response #### Success Response (void) This function does not return a value. ``` -------------------------------- ### Create a Simple Scatter Plot Source: https://www.npmjs.com/package/nodeplotlib?activeTab=dependents Demonstrates how to create a basic scatter plot using nodeplotlib. Ensure 'Plot' type is imported. ```typescript import { plot, Plot } from 'nodeplotlib'; const data: Plot[] = [ { x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'scatter', }, ]; plot(data); ``` -------------------------------- ### Plotting with Layout Options Source: https://www.npmjs.com/package/nodeplotlib/v/0.7.5?activeTab=dependents Demonstrates how to provide a `layout` object to customize plot appearance, such as titles and axis labels. ```APIDOC ## plot(data: Plot[], layout: Layout): void ### Description Plots the given data with specified layout options for customization. ### Method plot ### Parameters #### data - **data** (Plot[]) - Required - An array of Plot objects to be plotted. #### layout - **layout** (Layout) - Required - A Layout object for styling the plot. This is a partial of plotly's `Layout` type. ### Request Example ```javascript import { plot, Plot, Layout } from 'nodeplotlib'; const data: Plot[] = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout: Layout = { polar: { radialaxis: { visible: true, range: [0, 50] } }, title: 'Radial Plot Example' }; plot(data, layout); ``` ``` -------------------------------- ### Advanced Usage with Stack and Clear Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=code Demonstrates using `stack` to add multiple plots to a page and `plot` to render them, followed by `clear` to reset the stack. ```APIDOC ### Details The library provides a simple interface with (for now) just three functions. A `plot`, `stack` and a `clear` function. ``` import { plot, stack, clear } from 'nodeplotlib'; import { PlotData } from 'plotly.js'; const data: Partial[] = [{ x: [ 1, 3, 4, 6, 7], y: [ 2, 4, 6, 8, 9], type: 'scatter' }]; stack(data); stack(data); stack(data); plot(); ``` The `plot()` function plots all stacked plots and the plot given by parameter (if there is one). Afterwards the temporary container gets cleared and you can call `stack()` and `plot()` again without any predefined plots. The functions are of the form: ``` plot(data?: Partial[], layout?: Partial, cb?: Function): void; stack(data?: Partial[], layout?: Partial): void; clear(): void; ``` ``` -------------------------------- ### Plotting Stacked Data Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=versions Shows how to use the `stack` function to add multiple plot data sets to a stack, and then use `plot` to render them all. ```APIDOC ## stack(data, layout) ### Description Adds plot data to a temporary stack. This data will be plotted when `plot()` is called without arguments. ### Method stack ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (Partial[] | undefined) - Optional. An array of Plotly.js PlotData objects to stack. - **layout** (Partial | undefined) - Optional. Plotly.js layout object for styling. ### Request Example ```javascript import { plot, stack, clear } from 'nodeplotlib'; import { PlotData } from 'plotly.js'; const data: Partial[] = [{ x: [ 1, 3, 4, 6, 7], y: [ 2, 4, 6, 8, 9], type: 'scatter' }]; stack(data); stack(data); stack(data); plot(); // Plots all stacked plots ``` ### Response #### Success Response (void) This function does not return a value. ``` ```APIDOC ## plot(data?, layout?, cb?) ### Description Plots all stacked plots and the plot given by parameter (if there is one). Afterwards, the temporary container gets cleared. ### Method plot ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **data** (Partial[] | undefined) - Optional. An array of Plotly.js PlotData objects to plot. - **layout** (Partial | undefined) - Optional. Plotly.js layout object for styling. - **cb** (Function | undefined) - Optional. A callback function. ### Request Example ```javascript import { plot, stack } from 'nodeplotlib'; const data = [{x: [1, 2], y: [3, 4], type: 'bar'}]; stack([{x: [5, 6], y: [7, 8], type: 'bar'}]); plot(data); // Plots both the provided data and the stacked data ``` ### Response #### Success Response (void) This function does not return a value. ``` -------------------------------- ### Detailed Usage with Stack Source: https://www.npmjs.com/package/nodeplotlib/v/0.6.0?activeTab=dependencies Utilize `stack`, `plot`, and `clear` functions for managing multiple plots. ```APIDOC ### Detailed usage ```typescript import { plot, stack, clear, Plot } from 'nodeplotlib'; const data: Plot[] = [{ x: [ 1, 3, 4, 6, 7], y: [ 2, 4, 6, 8, 9], type: 'scatter' }]; stack(data); stack(data); stack(data); plot(); ``` The `plot` function plots all stacked plots and the plot given by parameter (if there is one). Afterwards the temporary container gets cleared and you can call `stack()` and `plot()` again without any predefined plots. The functions are of the form: ```typescript import { plot, stack, clear, Plot, Layout } from 'nodeplotlib'; plot(data?: Plot[], layout?: Layout): void; stack(data: Plot[], layout?: Layout): void; clear(): void; ``` ``` -------------------------------- ### Stacked Plotting Source: https://www.npmjs.com/package/nodeplotlib/v/0.5.0?activeTab=code Illustrates how to use the `stack` function to add multiple plots to a page before calling `plot()` to display them all. ```APIDOC ## stack(data: Plot[], layout?: Layout): void ### Description Adds plot data to a temporary container for later plotting. Multiple calls to `stack` allow for multiple charts on a single page. ### Method ```javascript stack(data: Plot[], layout?: Layout): void; ``` ### Parameters * **data** (Plot[]) - Required - An array of Plot objects to be stacked. * **layout** (Layout) - Optional - Layout object for plot styling. ### Request Example ```javascript import { plot, stack, Plot } from 'nodeplotlib'; const data: Plot[] = [{ x: [ 1, 3, 4, 6, 7], y: [ 2, 4, 6, 8, 9], type: 'scatter' }]; stack(data); stack(data); plot(); // Plots both stacked plots ``` ``` -------------------------------- ### Creating a Bar Chart Source: https://www.npmjs.com/package/nodeplotlib/v/0.4.2 Generates a bar chart with specified x and y data. ```javascript const trace: Plot = {x: [1, 2], y: [1, 2], type: 'bar'}; plot([trace]); ``` -------------------------------- ### Basic Plotting with NodePlotLib (TypeScript/JavaScript) Source: https://www.npmjs.com/package/nodeplotlib/v/0.7.7?activeTab=dependencies Import and use the 'plot' function to create a scatter plot. Requires 'Plot' type for data definition. ```typescript import { plot, Plot } from 'nodeplotlib'; const data: Plot[] = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'scatter'}]; plot(data); ``` -------------------------------- ### Basic Plotting with NodePlotLib Source: https://www.npmjs.com/package/nodeplotlib/v/0.4.0?activeTab=code Import the plot function and create a simple line plot with provided data. ```typescript import { plot, Plot } from 'nodeplotlib'; const data: Plot[] = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'line'}]; plot(data); ``` -------------------------------- ### Create a Bar Chart Source: https://www.npmjs.com/package/nodeplotlib?activeTab=dependents Generates a bar chart with specified x and y values. ```typescript const trace: Plot = { x: [1, 2], y: [1, 2], type: 'bar' }; plot([trace]); ``` -------------------------------- ### Customizing Plots with Layout Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.2?activeTab=dependents Illustrates how to use the `layout` parameter to customize plot appearance, such as titles and axis labels. ```APIDOC ## plot(data?: Partial[], layout?: Partial, cb?: Function): void ### Description Spawns a plot to the browser with the given plot data and layout options. ### Parameters * **data** (Partial[]): Optional. An array of Plotly.js PlotData objects to plot. * **layout** (Partial): Optional. Plotly.js layout object for styling the plot, including titles, axis labels, and subplots. * **cb** (Function): Optional. A callback function to be executed after plotting. ### Request Example ```javascript const data = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout = { polar: { radialaxis: { visible: true, range: [0, 50] } } }; plot(data, layout); ``` ``` -------------------------------- ### Radial Plots with Layout Source: https://www.npmjs.com/package/nodeplotlib/v/0.6.0?activeTab=dependencies Create radial plots and customize their appearance using the `layout` parameter. ```APIDOC #### Radial Plots In order to style the plot, one is able to pass in the `layout` parameter, which internally is typeof `Partial` from plotly's `Layout`. See the full layout documentation here. With this parameter one is able to define styles like _title_ , _axis labels_ , _subplots_ and many more. ```typescript const data: Plot[] = [{ type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A','B','C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B' }]; const layout: Layout = [ polar: { radialaxis: { visible: true, range: [0, 50] } } ]; plot(data, layout); ``` ``` -------------------------------- ### Plotting with Layout Source: https://www.npmjs.com/package/nodeplotlib?activeTab=readme Shows how to customize plots by providing a `layout` object to the `plot` function, enabling features like titles and axis configurations. ```APIDOC ## Plotting with Layout ### Description This example demonstrates how to customize a plot using the `layout` parameter, which accepts a `Layout` object for styling and configuration. ### Usage ```typescript import { plot, Plot, Layout } from 'nodeplotlib'; const data: Plot[] = [ { type: 'scatterpolar', r: [1.5, 10, 39, 31, 15, 1.5], theta: ['A', 'B', 'C', 'D', 'E', 'A'], fill: 'toself', name: 'Group B', }, ]; const layout: Layout = { polar: { radialaxis: { visible: true, range: [0, 50], }, }, }; plot(data, layout); ``` ``` -------------------------------- ### Basic Plotting with NodePlotLib Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=readme Import the plot function and use it to create a simple line plot with provided data. This is the most basic usage for generating a plot. ```javascript import { plot } from 'nodeplotlib'; const data = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'line'}]; plot(data); ``` -------------------------------- ### Line Plots Source: https://www.npmjs.com/package/nodeplotlib/v/0.6.0?activeTab=dependencies Create line plots using the `plot` function. ```APIDOC #### Line Plots ```typescript const trace1: Plot = {x: [1, 2], y: [1, 2], type: 'scatter'}; const trace2: Plot = {x: [3, 4], y: [9, 16], type: 'scatter'}; plot([trace1, trace2]); ``` ``` -------------------------------- ### Creating a 3D Surface Plot Source: https://www.npmjs.com/package/nodeplotlib/v/0.4.2 Generates a 3D surface plot using z-axis data and a specified colorscale. ```javascript const trace: Plot = {colorscale: 'Viridis', z: [[3, 5, 7, 9], [21, 13, 8, 5]]}; plot([trace]); ``` -------------------------------- ### plot Function Source: https://www.npmjs.com/package/nodeplotlib/v/0.3.1?activeTab=versions Spawns a plot to the browser. If plot data is given as an argument, it plots that data. Otherwise, it plots all stacked plot data. It can also accept layout options and a callback function. ```APIDOC ## plot ### Description Spawns a plot to the browser. If plot data is given as an argument, it plots that data. Otherwise, it plots all stacked plot data. It can also accept layout options and a callback function. ### Signature ```typescript plot(data?: Partial[], layout?: Partial, cb?: Function): void; ``` ### Parameters * **data** (Partial[]): Optional. An array of plot data objects. * **layout** (Partial): Optional. Layout configuration for the plot. * **cb** (Function): Optional. A callback function to be executed after plotting. ### Example ```javascript import { plot } from 'nodeplotlib'; const data = [{x: [1, 3, 4, 5], y: [3, 12, 1, 4], type: 'line'}]; plot(data); ``` ``` -------------------------------- ### Function Signatures Source: https://www.npmjs.com/package/nodeplotlib/v/0.2.8?activeTab=code The explicit function signatures for `plot`, `stack`, and `clear`. ```APIDOC The functions are of the form: ``` plot(data?: Partial[], layout?: Partial, cb?: Function): void; stack(data?: Partial[], layout?: Partial): void; clear(): void; ``` ```