Plotly is free for unlimited public use. Sign up for free!

Sensitive data? Upgrade to a paid plan

  • Open Source.
    These libraries are free forever. Your Pro plan helps keep them top notch.
  • Share Online.
    Share charts, dashboards, Jupyter notebooks, and presentations through our enterprise-grade cloud.
  • Engineering Support.
    Get instant chat support from our awesome engineering team.
Show Sidebar Hide Sidebar

Getting Started with Plotly for Node.js

Plotly's Node.js graphing library makes interactive, publication-quality graphs online. Examples of how to make line plots, scatter plots, area charts, bar charts, error bars, box plots, histograms, heatmaps, subplots, multiple-axes, polar charts and bubble charts.

Getting started with Plotly for Nodejs

Installation

To install Plotly's Node module, use npm.

npm install plotly

Authentication

Fire up Node!

$ node
var plotly = require('plotly')("DemoAccount", "lr1c37zw81")

You'll need to replace "DemoAccount" and "lr1c37zw81" with your Plotly username and API key.

Find my API key.


Special Instructions for Plotly On-Premise users

Your API key for account on the public cloud will be different than the API key in Plotly On-Premise. Visit https://plotly.your-company.com/settings/api/ to find your Plotly On-Premise API key. Remember to replace "your-company.com" with the URL of your Plotly On-Premise server.

Instantiate your plotly object with the domain of your Plotly On-Premise server.

var plotly = require('plotly')({"username": "DemoAccount", "apiKey": "lr1c37zw81", "host": "plotly.your-company.com", "port": 443})

Remember to replace "your-company.com" with the URL of your Plotly On-Premise server. Questions? support@plot.ly

Start plotting!

Copy and paste the following to create your first graph using the Plotly Node library! If all goes well, the URL for your graph will be printed in your console.


var data = [{x:[0,1,2], y:[3,2,1], type: 'bar'}];
var layout = {fileopt : "overwrite", filename : "simple-node-example"};

plotly.plot(data, layout, function (err, msg) {
	if (err) return console.log(err);
	console.log(msg);
});

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to our Premium or Enterprise plans.