chung
July 5, 2024, 2:28am
1
WIth the following
var data = [
{
y: ['giraffes', 'orangutans', 'monkeys'],
x: [20, 14, 23],
type: 'bar',
orientation: 'h',
}
];
Plotly.newPlot('myDiv', data);
And you can see the order of the y data
['giraffes', 'orangutans', 'monkeys']
is ordered from the bottom to top. How do I reverse the order for the bars(without changing the arrays)?
yaxis: { autorange: "reversed" } }
chung
July 5, 2024, 2:43am
3
Do you mean
var data = [
{
y: ['giraffes', 'orangutans', 'monkeys'],
x: [20, 14, 23],
type: 'bar',
orientation: 'h',
+ yaxis: { autorange: "reversed" }
}
];
With the additional line, there is no visual change on the cahrt.
yaxis goes in the layout properties
var data = [
{
y: ['giraffes', 'orangutans', 'monkeys'],
x: [20, 14, 23],
type: 'bar',
orientation: 'h'
}
];
var layout = {
yaxis: {
autorange: "reversed"
}
}
Plotly.newPlot('myDiv', data, layout);