Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force plotly to display x axis numbers as categories?

I have a dataset where I'm referring to samples as numbers - when I try and do a bar graph using plotly (in JS) it's treating them as numbers and not as a label. How can I turn that off?

like image 485
BZ. Avatar asked May 10 '16 22:05

BZ.


People also ask

How do you set the X-axis range in Plotly?

Setting the Range of Axes Manually The visible x and y axis range can be configured manually by setting the range axis property to a list of two values, the lower and upper boundary. Here's an example of manually specifying the x and y axis range for a faceted scatter plot created with Plotly Express.

How do you show figures in Plotly?

To display a figure using the renderers framework, you call the . show() method on a graph object figure, or pass the figure to the plotly. io. show function.

How do you hide X-axis labels in Plotly?

How do you remove X-axis labels from Plotly? The axis tick mark labels can be disabled by setting the showticklabels axis property to False .


1 Answers

You can override plotly's axis auto-type routine by specifying the axis type. For example,

var data = [/* your data */];

var layout = {
   xaxis: { type: 'category' }
};

Plotly.plot('graph', data, layout);
like image 173
etpinard Avatar answered Oct 21 '22 02:10

etpinard