QwtPlot 自定义轴

发布于 2024-12-10 12:09:24 字数 170 浏览 0 评论 0原文

我想创建带有两个水平轴的绘图。底部轴是线性的,顶部轴是非线性的。我有一个用于转换的数据表“底部值 -> 顶部值”。我发现 QwtScaleEngine 提供了此功能。但我无法让它工作,因为有太多记录错误的函数需要在 QwtScaleEngine 和 QwtScaleDiv 的子类中定义。

有什么建议吗?

I want to create plot with two horizontal axes. Bottom axis is linear, top axis is non-linear. I have a table of data for conversion "Bottom value -> top value". I found out that QwtScaleEngine provides this functionality. But I can't make it work because there're too many badly documented functions to define in subclasses of QwtScaleEngine and QwtScaleDiv.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初懵 2024-12-17 12:09:24

您是否希望两个水平轴有效地覆盖共享一个轴的两个图,或者只是提供第一个水平轴的附加表示(例如不同的单位)?这可能不太相关,我只是想了解你的问题。

我首先建议您查看 QwtPlot::updateAxes()文档。这是我在 Qwt 官方文档中找到的关于绘图、比例引擎和比例划分之间关系的最好描述。虽然我不认为 Qwt 的文档记录得很差,但我确实认为它缺乏对概念的高级描述。

我认为 QwtScaleDiv 更多的是一种容器类型,包含轴边界和潜在的刻度值。我不认为您有必要子类化 QwtScaleDiv。

您是正确的 QwtScaleEngine 参与此转换,但有至少在 Qwt 6.1.0 中还有更多内容。 QwtScaleEngine 支持转换概念 (QwtTransform )与 setTransformation()。如果您的转换是一个简单的数学函数,例如对数、指数、二次、三次函数等,您应该能够使用 QwtPowerTransformQwtLogTransform。如果这些不适用,您可以实现自己的 QwtTransform 并将其分配给 QwtScaleEngine。据我所知,转换必须是双向的,即同时实现 transforminvTransform。根据我的经验,它还必须转换与比例引擎关联的轴关联的所有绘图项的值,包括网格线、区域等。除了默认 QwtLinearScaleEngine,但这效果很好。这是一个强大的概念。另外,请查看 SVN 游乐场 (6.1.0)。

Do you want two horizontal axes to effectively overlay two plots that share an axis, or just to provide an additional representation (e.g. different unit) of the first horizontal axis? It might not be all that relevant, I'm just trying to understand your problem.

I would first recommend you have a look at the QwtPlot::updateAxes() documentation. It is the best description I have found of the relationship between a plot, scale engines and scale divisions in the official Qwt documentation. While I don't think Qwt is badly documented, I do think it lacks a high-level description of the concepts.

QwtScaleDiv I see as more of a container type, containing the axis boundaries and potentially the tick values. I can't see that it is necessary for you to subclass QwtScaleDiv.

You are correct that QwtScaleEngine is involved in this conversion, but there is a little more to it, at least in Qwt 6.1.0. QwtScaleEngine supports a transformation concept (QwtTransform) with setTransformation(). If your conversion is a simple mathematical function such as a logarithmic, exponential, quadratic, cubic function etc, you should be able to use QwtPowerTransform or QwtLogTransform. If these aren't applicable you can implement your own QwtTransform and assign it to a QwtScaleEngine. As far as I know, the transformation must be two-way, meaning implementing both transform and invTransform. In my experience it must also transform values for all plot items associated with the axis that the scale engine is associated with, including grid lines, zones etc. I have not tried using transformations on other scale engines than the default QwtLinearScaleEngine, but that has worked great. It's a powerful concept. Also, have a look at the scaleengine example in the SVN playground (6.1.0).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文