如何强制绘图将x轴编号显示为类别

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

本文关键字:显示 编号 何强制 绘图      更新时间:2023-09-26

我有一个数据集,我将样本称为数字——当我尝试使用plotly(在JS中)绘制条形图时,它将它们视为数字,而不是标签。我该怎么关掉它?

您可以通过指定轴type来覆盖plotly的轴自动类型例程。例如,

var data = [/* your data */];
var layout = {
   xaxis: { type: 'category' }
};
Plotly.plot('graph', data, layout);