javascript - 如何使用 Plotly 在散点极坐标图中使用径向轴值创建圆形带
问题描述
我想在 scatterpolar 图表内创建一个圆形带,如下所示:
对于绘图带,我想提供两个输入:径向轴的 R_inner 和 R_outer 值,以便我可以修改带的厚度。
在当前图像中,我使用带有大小的标记绘制了波段。我给出的 HTML,JS 代码如下:
function getrandom(num, mul) {
var value = []
for (i = 0; i <= num; i++) {
rand = Math.random() * mul;
value.push(rand);
}
return value;
};
function get_update_data() {
var data = [{
type: "scatterpolargl",
r: [50],
theta: [0],
mode: "markers",
name: "Wall Radius",
marker: {
color: "green",
size: 10,
line: {
color: "white"
},
opacity: 1
},
cliponaxis: false
},
{
type: "scatterpolargl",
r: [0],
theta: [0],
mode: "markers",
name: "Band",
marker: {
symbol: "circle-open",
color: "red",
"sizemode": "diameter",
size: 200,
line: {
width: 30
},
opacity: 0.3
},
cliponaxis: true
},
];
return data;
};
var layout = {
title: "",
font: {
size: 15
},
polar: {
bgcolor: "rgb(255, 255, 255)",
angularaxis: {
tickwidth: 2,
linewidth: 3,
color: "rgb(0,153,204)",
layer: "below traces"
},
radialaxis: {
side: "counterclockwise",
showline: false,
tickwidth: 0,
showgrid: true,
color: "rgb(0,153,204)",
ticks: "",
showticklabels: true,
}
},
paper_bgcolor: "rgb(255,255,255)",
autosize: false,
width: 400,
height: 400,
margin: {
l: 10,
r: 10,
b: 50,
t: 50,
pad: 4
},
};
function get_update_layout() {
return layout;
};
Plotly.newPlot('myDiv', get_update_data(), layout);
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="myDiv">
<!-- Plotly chart will be drawn inside this DIV -->
</div>
<script>
<!-- JAVASCRIPT CODE GOES HERE -->
</script>
</body>
解决方案
推荐阅读
- python - 有没有办法从外部对字典进行排序
- android - 在创建移动应用程序时,我们如何摆脱 android 和 ios 环境?
- mysql - 向 mysql gcp 实例添加私有 IP 时出现问题
- cucumber - 如何在 WebdriverIO 中使用 Cucumber 标签运行“标记”场景
- vue.js - 在构建时更改 manifest.json 文件中的属性
- python - 气流计划间隔更改
- blender - Blender UV Sphere 导出为 GLTF
- php - PHP:加载 JS 事件后获取远程页面
- arrays - 根据数组中 I 时间的每个持续时间播放快速声音
- vba - MS Access 2016 VBA 错误“无效操作”它在第二个 CASE 中显示第一个 IF 语句的错误