plot - 可以用 jsxgraph 制作波特图
问题描述
我正在拼命寻找如何将图表放在 jsxgraph 下以绘制带有 x 轴的图表,该图表以对数方式演变。像这样https://en.wikipedia.org/wiki/Bode_plot
谢谢你的帮助,
解决方案
这是一个如何使用对数垂直轴进行绘图的示例。它改编自 Murray Bourne 的示例,请参阅https://www.intmath.com/cg3/jsxgraph-coding-summary.php。代码如下所示:
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 6, 5, -4], axis:false
});
// Vertical axis with logarithmic scale
var attr = JXG.Options.board.defaultAxes.x;
attr.ticks.drawZero = false;
var xAxis = board.create('axis', [[0, 0], [1, 0]], attr);
attr = JXG.Options.axis;
var yAxis = board.create('line', [[0, 0], [0, 1]], attr);
attr = JXG.Options.board.defaultAxes.y.ticks;
attr.drawLabels = true;
attr.drawZero = false;
attr.generateLabelText = function (tick, zero) {
return (Math.pow(10, Math.round(tick.usrCoords[2] - zero.usrCoords[2]))).toString();
}
var ticksY = board.create('ticks', [yAxis, 1], attr);
// Plot two functions
var post = (x) => JXG.Math.log10(x);
var f1 = (x) => x*x;
var f2 = (x) => Math.exp(x);
board.create('functiongraph', [(x) => post(f1(x))], {
name: 'x^2',
withLabel: true
});
board.create('functiongraph', [(x) => post(f2(x))], {
name: 'e^x',
withLabel: true,
strokeColor: 'red'
});
推荐阅读
- r - R:如何设置名称以列出对象和子对象
- mongodb - 来自 mongot :: 的远程错误由 :: 查询导致内部扩展为太多子查询:maxClauseCount 设置为 1024
- c# - 将 GUID 正确存储为 SQL Server 数据库中的 UUID
- javascript - 在一个 PNG 图像中包含多个布局图像的 HTTP 响应
- java - 您将如何解决“httpservlet 无法解决类型”错误?
- reactjs - 为什么我的复选框在 ReactJS 中取消选中后不返回
- reactjs - 在其父 const React js 之外访问嵌套的 const
- java - Java 11 升级后 Eclipse Spring Tools Suite 缺少 JDK 警告
- pandas - 使用列信息将数据框重塑为新的单列
- r - 如何在 dplyr 的 purrr 映射中使用动态变量