Javascript Plotly.js创建堆叠和分组条形图
如何在Plotly.js上使用分组和堆叠的条形图创建条形图?我需要这样的结构:Javascript Plotly.js创建堆叠和分组条形图,javascript,plotly,plotly.js,Javascript,Plotly,Plotly.js,如何在Plotly.js上使用分组和堆叠的条形图创建条形图?我需要这样的结构: 通过将每组创建为子批次,可以在Plotly.js中创建分组和堆叠条形图。它不像设置“barmode”这样的顶级功能那样简单:“stacked+grouped”,但因为它更基本,所以提供了更多选项 看 这里,每个子地块引用一个共享的公共yaxis和它自己的xaxis。每个xaxis都有一个“域”,这里指的是整个底轴宽度的一部分。第一组得到[0.0,0.33],第二组得到[0.34,0.66],第三组得到[0.67,1.
通过将每组创建为子批次,可以在Plotly.js中创建分组和堆叠条形图。它不像设置“barmode”这样的顶级功能那样简单:“stacked+grouped”,但因为它更基本,所以提供了更多选项 看 这里,每个子地块引用一个共享的公共yaxis和它自己的xaxis。每个xaxis都有一个“域”,这里指的是整个底轴宽度的一部分。第一组得到[0.0,0.33],第二组得到[0.34,0.66],第三组得到[0.67,1.0]
通过将每个组创建为子批次,可以在Plotly.js中创建分组和堆叠条形图。它不像设置“barmode”这样的顶级功能那样简单:“stacked+grouped”,但因为它更基本,所以提供了更多选项 看 这里,每个子地块引用一个共享的公共yaxis和它自己的xaxis。每个xaxis都有一个“域”,这里指的是整个底轴宽度的一部分。第一组得到[0.0,0.33],第二组得到[0.34,0.66],第三组得到[0.67,1.0] 我建议你阅读这一页,改进你的问题。这里没有描述您可能面临的具体问题,因此除了链接到我建议您阅读该页面并改进您的问题之外,您不太可能获得任何信息。这里没有描述您可能面临的具体问题,因此除了链接到
Plotly.newPlot(
"myDiv",
[
{
x: ["A", "B", "C"],
y: [0.3, 0.35, 0.4],
type: "bar",
name: "series 1a",
xaxis: 'x1',
barmode: 'stack',
marker: {color: '#448'}
},
{
x: ["A", "B", "C"],
y: [0.6, 0.50, 0.40],
type: "bar",
name: "series 1b",
xaxis: 'x1',
barmode: 'stack', marker: {color: '#88C'}
},
{
x: ["A", "B", "C"],
y: [0.1, 0.15, 0.20],
type: "bar",
name: "series 1c",
xaxis: 'x1',
barmode: 'stack',
marker: {color: '#CCF'}
},
{
x: ["A", "B", "C"],
y: [0.3, 0.35, 0.4],
type: "bar",
name: "series 2a",
xaxis: 'x2',
barmode: 'stack', marker: {color: '#080'}
},
{
x: ["A", "B", "C"],
y: [0.25, 0.15, 0.05],
type: "bar",
name: "series 2b",
xaxis: 'x2',
barmode: 'stack', marker: {color: '#8c8'}
},
{
x: ["A", "B", "C"],
y: [0.45, 0.50, 0.55],
type: "bar",
name: "series 2c",
xaxis: 'x2',
barmode: 'stack', marker: {color: '#CFC'}
},
{
x: ["A", "B", "C"],
y: [0.3, 0.35, 0.4],
type: "bar",
name: "series 3a",
xaxis: 'x3',
barmode: 'stack', marker: {color: '#880'}
},
{
x: ["A", "B", "C"],
y: [0.6, 0.50, 0.40],
type: "bar",
name: "series 3b",
xaxis: 'x3',
barmode: 'stack', marker: {color: '#CC8'}
},
{
x: ["A", "B", "C"],
y: [0.1, 0.15, 0.20],
type: "bar",
name: "series 3c",
xaxis: 'x3',
barmode: 'stack', marker: {color: '#FFC'}
},
],
{
barmode: "stack",
yaxis: {tickformat: '%'},
xaxis: {
domain: [0, 0.33],
anchor: 'x1',
title: 'Apples'
},
xaxis2: {
domain: [0.33, 0.66],
anchor: 'x2', title: 'Pears'
},
xaxis3: {
domain: [0.67, 1.0],
anchor: 'x3', title: 'Cherries'
}
}
);