umnomefixe
umnomefixe

Reputation: 13

Axes labels/titles not appering plotly.js

So I'm using Plotly.js to plot a 3D scatter plot and I'm trying to change the labels of each axes. On the Plotly page says that I have to do this (The dims list contains the axes' names.):

  var layout = {
    margin: {
      l: 0,
      r: 0,
      b: 0,
      t: 0
  },
  xaxis : {
    title : {
      text : dims[0]
    }
  },

  yaxis : {
    title : {
      text : dims[1]
    }
  },

  zaxis : {
    title : {
      text : dims[2],
    }
  }};

But by doing so I still get the axes' names to be x,y and z.

If I go on the console and type

$0.layout.zaxis.title

I get the right title for the Z axis but on the plot it self it shows this:

enter image description here

Please help :)

Upvotes: 0

Views: 823

Answers (1)

Mihajlo T.
Mihajlo T.

Reputation: 356

I stumbled accross this as well. What you need to do is to add desired titles in scene object, like this:

var layout = {
    margin: {
      l: 0,
      r: 0,
      b: 0,
      t: 0,
    },
    scene: {
      xaxis: { title: "X AXIS TITLE" },
      yaxis: { title: "Y AXIS TITLE" },
      zaxis: { title: "Z AXIS TITLE" },
    },
  };

Upvotes: 5

Related Questions