How to show all x-axis tick values in Plotly?

omega picture omega · Jan 13, 2016 · Viewed 17.1k times · Source

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

Answer

Finrod Felagund picture Finrod Felagund · Jun 27, 2018

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')