26

I am using this library

https://plot.ly/nodejs/axes/

to plot graphs in node.js. I have this code:

var data = [
  {
    x: xs,
    y: ys,
    type: "scatter"
  }
];

var graphOptions = {filename: "date-axes", fileopt: "overwrite"};
plotly.plot(data, graphOptions, function (err, msg) {
    console.log(msg);
    console.log("DONE!");
});

to plot a graph with 5000 x-axis points. The problem is that in the rendered image, it x-axis values are not continuously increment by for each value I put. There is a rather large step, for example, if the x-axis labels are

['item1', 'item2', ..., 'item5000']

then it outputs with labels

['item1', 'item10', ..., 'item5000']

All the yaxis points are there, but I just want to see all x-axis labels.

Does anyone know what setting enables this? I assume that they did this by default so the text labels don't overlap each other, but in my case I want to see them all.

Thanks

Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53
omega
  • 40,311
  • 81
  • 251
  • 474

3 Answers3

43

I am using Python, though I have encountered the same problem. When you are specifying the layout of your chart, you need to set tickmode='linear', at least it worked for me!

import plotly 
import plotly.plotly as py
import plotly.graph_objs as go

layout = go.Layout(
    title='some title',
    xaxis=dict(
        title='Xaxis Name',
        tickmode='linear')
phoenix
  • 7,988
  • 6
  • 39
  • 45
Finrod Felagund
  • 1,231
  • 2
  • 14
  • 18
11

Use layout.xaxis.dtick

Example here: https://plot.ly/nodejs/axes/

etpinard
  • 4,756
  • 1
  • 20
  • 26
7

I run into the same problem and I managed to solve it: the trick is to define your values on xaxis as "categorical". This is what my code looked like:

var layout = {
        xaxis: {
            tickangle: 35,
            showticklabels: true,
            type: 'category',
        }
    };
    Plotly.newPlot(divname, data, layout);
polyccon
  • 681
  • 7
  • 9