Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

How do I assign the title of a chart for the plotly.getImage method

I’m using the Plotly Node.js API. Where do I assign the title of a chart when using the plotly.getImage method? I know you can do it in graphOptions when you use plotly.plot, but where would I put it in the code below??

    var plotly = require('plotly')('username','apiKey');
    var fs = require('fs');

    var trace1 = {
      x: [1, 2, 3, 4],
      y: [10, 15, 13, 17],
      type: "scatter"

    var figure = { 'data': [trace1] };

    var imgOpts = {
        format: 'png',
        width: 1000,
        height: 500

    plotly.getImage(figure, imgOpts, function (error, imageStream) {
        if (error) return console.log (error);

        var fileStream = fs.createWriteStream('1.png');

I figured it out.

var trace = {
values: values,
labels: labels,
type: "pie"
// Here we go! 
var layout = {
title: "Weekly Pie Chart Overnights",
font: {
family: "Courier New, monospace",
size: 18,
color: "#7f7f7f"
// and just put that object in the figure object!!!
var figure = { 'data': [trace], layout: layout };

var imgOpts = {
  format: 'png',
  width: 1000,
  height: 500,