|
3D Scatter Plot and Line layer |
Posted by Gary Hart on Jul-20-2022 15:18 |
|
Hi All,
I am hoping that this is even possible, but can a 3D scatter plot have a line layer as well connecting each of the data points?
I have data that I am plotting that has x,y,z values and a time stamp. The x,y,z data plots fine as a 3D scatter plot, but I would like to also use the time stamp to put a line layer in that connects each of the data points in time order.
I have seen this done with Python and Matplotlib, but I don't want to use either of those. I am using Perl with ChartDirector and the Xojo port of ChartDirector.
Any ideas would be appreciated.
Thank you.
Gary Hart. |
Re: 3D Scatter Plot and Line layer |
Posted by Peter Kwan on Jul-21-2022 01:07 |
|
Hi Gary,
After laying out the 3D scatter chart (calling BaseChart.layout), you can use ThreeDChart.getXCoor and ThreeDChart.getYCoor to obtain the pixel (x, y) coordinates given the 3D data coordinates. You can then use BaseChart.addLine to add a line segment connecting the two points.
I have attached an example in Perl for your reference.
Best Regards
Peter Kwan |
Re: 3D Scatter Plot and Line layer |
Posted by Peter Kwan on Jul-21-2022 01:08 |
|
Hi Gary,
Here are the attachments.
Best Regards
Peter Kwan
|
Re: 3D Scatter Plot and Line layer |
Posted by Gary Hart on Jul-21-2022 14:08 |
|
Hi Peter,
Thank you for your reply to my query. Thank you also for the example that shows what to do to get the line layer to work. I have modified your example to use data from my database and in Perl it works perfectly. Using the line layer really shows up the outliers in the data well.
The Xojo version however does not work. It just draws a single line between 2 random points on the plot. The points used seem to have no association with the location of the data points. This, however is not your problem, I will email MonkeyBread Software about it and see if they can help.
Thank you for your help.
Gary Hart. |
Re: 3D Scatter Plot and Line layer |
Posted by Rick Issen on Aug-03-2023 20:01 |
|
Hi Peter,
Your solution is fine for one series/graph/polyline, but if there are more series, then the z-order of the lines is incorrect; it also depends on the three different 3D angles.
It will be much simpler for us when you provide the polyline directly in one of the lib functions!
Regards,
Rick |
Re: 3D Scatter Plot and Line layer |
Posted by Peter Kwan on Aug-04-2023 15:37 |
|
Hi Rick,
Currently, ChartDirector can only draw lines as a surface texture (eg. grid lines), or handle it like text labels, that is, drawn without regarding to z-order.
We will investigate to see if we can implement true 3D line in a future version of ChartDirector.
We noted that both Direct3D and OpenGL do not have primitives for "lines". In 2D graphics, a line has to be drawn as a long and thin rectangle (1D line cannot be visible as it has no area). In 3D graphics, a line needs to be generated as a 3D tube, otherwise it does not look right in certain view angles. A 3D polyline is a long tube twisted in various ways and can intersect and poke through itself and other objects, so it is not as trivial as it seems.
Best Regards
Peter Kwan |
Re: 3D Scatter Plot and Line layer |
Posted by Rick Issen on Aug-04-2023 18:08 |
|
Hi Peter,
Now I understand the reason why 3D polyline series are not implemented inside the scatter chart...
Related Question: When comes out the next CD release?
Best Regards,
Rick |
|