简体   繁体   English

Qt 3D散点图:如何调整轴的比例?

[英]Qt 3D scatter graph: how can I adjust the scale of an axis?

I'm currently developing a Qt desktop application using the Q3DScatter class. 我目前正在使用Q3DScatter类开发Qt桌面应用程序。 I'm inspecting Qt's 3D Scatter example project and I tried to modify the data item set to plot my own data. 我正在检查Qt的3D Scatter示例项目,我尝试修改数据项集来绘制我自己的数据。 The data is plotted except that one axis is not well scaled and my 3D plot looks really messy. 绘制数据,但一个轴没有很好地缩放,我的3D绘图看起来非常混乱。 I'm looking for a way to adjust this axis. 我正在寻找一种调整此轴的方法。 I've tried to change the range and the segment count of the axis, I even tried to set the "AutoAdjustRange" of the axis to true, but nothing seemed to solve the problem. 我试图改变轴的范围和段数,我甚至试图将轴的“AutoAdjustRange”设置为true,但似乎没有解决问题。

Would really appreciate some help. 非常感谢一些帮助。

PS: Here's a screen capture of what my 3D scatter graph looks like (the "messy" axis is shown with the red arrow) PS:这是我的3D散点图看起来像的屏幕截图(“杂乱”轴用红色箭头显示)

在此输入图像描述

I figured this out by creating a CustomFormatter class by subclassing QValue3DAxisFormatter and reimplementing some of its functions (I followed this tutorial ). 我通过QValue3DAxisFormatter创建一个CustomFormatter类并重新实现它的一些功能(我遵循本教程 )来解决这个问题 Then I set up my axis formatter to my custom formatter ( m_graph->axisZ()->setFormatter(cf); ). 然后我将我的轴格式化程序设置为我的自定义格式化程序( m_graph->axisZ()->setFormatter(cf); )。

Subclassing QValue3DAxisFormatter will not work: it determines where ticks and labels are placed, but not how large the axex actually are. 子类化QValue3DAxisFormatter将不起作用:它确定放置刻度和标签的位置,但不确定轴实际有多大。

To do that, you can set the (horizontal) aspect ratio, that is a property of Q3DScatter . 为此,您可以设置(水平)宽高比,即Q3DScatter的属性。 The following settings will make the data into a cube volume: 以下设置将使数据成为多维数据集卷:

plot->setAspectRatio(1.0);
plot->setHorizontalAspectRatio(1.0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM