Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Qt Data Visualization adjust axis scaling

Qt Data Visualization adjust axis scaling

Scheduled Pinned Locked Moved Unsolved Qt for Python
pysidepythonqt for python
1 Posts 1 Posters 439 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ccortez
    wrote on 3 Aug 2022, 19:26 last edited by
    #1

    I am currently plotting 3D figures using Q3DScatter and I am running into an issue with adjusting scales on an axis. The 3D figure that is rendering is very out of scale and too "squished".

    Here is a picture to show what I mean:
    scatter3d_wrongscaling.png

    As you can see, the values of the axis on the bottom (x axis) go all the way up to 195. The data on this axis gets shrunk and makes it look very squished when it should be stretched out a bit more. This has happened on other 3d models, but it is having the most effect on this one specifically. I've tried changing aspect ratios but I haven't really found anything that can let me change the axis scaling.

    It would be helpful to know if there is a way to do this or if it is not built to be customized that way. Any help or guidance is appreciated.

    Here is a sample of my code, you can assume all the proper libraries are imported:

    class ScatterGraph(QObject):
        def __init__(self, x, y, z):
            super(ScatterGraph, self).__init__()
            #self.setWindowTitle('3D Visualization')
            self.scatter = Q3DScatter()
            self.scatter.setFlags(self.scatter.flags() ^ Qt.FramelessWindowHint)
            self.container = QWidget.createWindowContainer(self.scatter)
            sc_sze = self.scatter.screen().size()
            self.container.setMinimumSize(QSize(sc_sze.width() / 2, sc_sze.height() / 1.6))
            self.container.setMaximumSize(sc_sze)
            self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            self.container.setFocusPolicy(Qt.StrongFocus)
            self.container.setWindowTitle('3D Visualization')
    
            data = []
            i = 0
            while i < len(x) - 25:
                data.append(QScatterDataItem(QVector3D(y[i], z[i], x[i])))
                i += 25
            self.series = QScatter3DSeries()
            self.series.dataProxy().addItems(data)
            self.scatter.addSeries(self.series)
            self.scatter.setAspectRatio(0.5)
            self.scatter.setHorizontalAspectRatio(1.0)
            self.scatter.show()
            self.container.show()
            self.container.setAttribute(Qt.WA_DeleteOnClose)
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        data = 'myfile.txt'
        df = pd.read_csv(data)
        x = list(df['X Position (mm)'].values)
        y = list(df['Y Position (mm)'].values)
        z = list(df['Z Position (mm)'].values)
        plot = ScatterGraph(x,y,z)
        sys.exit(app.exec())
    
    1 Reply Last reply
    0

    1/1

    3 Aug 2022, 19:26

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved