<html>
<script src="/lib/graphics/plotly.js"></script>
<body>
<div id="myPlot" style="width:100%;max-width:700px"></div>
<script>
var exp = "Math.cos(x)";
// 生成值
var xValues = [];
var yValues = [];
for (var x = 0; x <= 10; x += 0.2) {
yValues.push(eval(exp));
xValues.push(x);
}
// 使用 Plotly 来显示
var data = [{x:xValues, y:yValues, mode:"markers"}];
var layout = {title: "y = " + exp};
Plotly.newPlot("myPlot", data, layout);
</script>