Important: Please read the Qt Code of Conduct -

How to instantiate QScatterSeries dynamically for multiple data sets so I can paint them separately and plot into a Q3DScatter?

  • So I'm trying to plot a 3D scatter. I have multiple data sets to plot and each one must have a different color. We can only change color of entire series associated with a scatter, so I have to create multiple series for my scatter, and change the color of each series.

    My data is stored in .txt files, during the execution the user selects the data sets to plot and it's color, the address of those data set files is saved in matrix alongside the desired colors of each data set then during plot I open those files and load the data to a matrix of float numbers.

    The issue is: I don't know how many data sets I will plot. How can I instantiate multiple series during execution to hold data for those multiple data set so I can paint them separately?

    I tried to use a Qlist that contains QScatterSeries. Then I append the data in this list. I expected that each item in the list would be a different series but when I tried to paint each series in the Qlist the program painted the entire thing one color as if it was a single series only.

    My solution was to create ifs that based on how many data sets were selected to plot will instantiated a different number of series (up to 3 series) inside each if case. But this is ugly, we have multiple blocks of ifs that are never used and it limits the number of data sets we can use.

    Any solution to this?

Log in to reply