Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 688
omega Avatar asked Jan 12 '16 23:01

omega


2 Answers

Use layout.xaxis.dtick

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

like image 38
etpinard Avatar answered Sep 25 '22 09:09

etpinard


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')
like image 183
Finrod Felagund Avatar answered Sep 25 '22 09:09

Finrod Felagund