Skip to content

Low precision of scatter3d plot #5346

Closed
@Koushikphy

Description

@Koushikphy

I have this data that varies slowly in magnitude. If I plot this using Plotly's 2D scatter plot then it comes out okay, but get the following weired behaviour when I try to plot it using scatter3d. It seems scatter3d can't consider the slight change in value and plots it as a straight line with constant value.

Here's a sample script to generate the issue.

<!DOCTYPE html>
<body>
    <div id="graph1" style="height: 40vh;"></div>
    <div id="graph2" style="height: 60vh;"></div>
    <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
    <script>

        var data =[[0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02,0.02],[0,0.03490659,0.06981317,0.10471976,0.13962634,0.17453293,0.20943951,0.2443461,0.27925268,0.31415927,0.34906585,0.38397244,0.41887902,0.45378561,0.48869219,0.52359878,0.55850536,0.59341195,0.62831853,0.66322512,0.6981317,0.73303829,0.76794487,0.80285146,0.83775804,0.87266463,0.90757121,0.9424778,0.97738438,1.01229097,1.04719755,1.08210414,1.11701072,1.15191731,1.18682389,1.22173048,1.25663706,1.29154365,1.32645023,1.36135682,1.3962634,1.43116999,1.46607657,1.50098316,1.53588974,1.57079633,1.60570291,1.6406095,1.67551608,1.71042267,1.74532925,1.78023584,1.81514242,1.85004901,1.88495559,1.91986218,1.95476876,1.98967535,2.02458193,2.05948852,2.0943951,2.12930169,2.16420827,2.19911486,2.23402144,2.26892803,2.30383461,2.3387412,2.37364778,2.40855437,2.44346095,2.47836754,2.51327412,2.54818071,2.58308729,2.61799388,2.65290046,2.68780705,2.72271363,2.75762022,2.7925268,2.82743339,2.86233997,2.89724656,2.93215314,2.96705973,3.00196631,3.0368729,3.07177948,3.10668607,3.14159265],[-527.1404441,-527.140444,-527.1404439,-527.1404437,-527.1404435,-527.1404431,-527.1404427,-527.1404422,-527.1404417,-527.1404411,-527.1404404,-527.1404396,-527.1404388,-527.1404379,-527.1404369,-527.1404359,-527.1404348,-527.1404336,-527.1404324,-527.1404311,-527.1404298,-527.1404284,-527.140427,-527.1404254,-527.1404239,-527.1404223,-527.1404207,-527.140419,-527.1404172,-527.1404154,-527.1404136,-527.1404118,-527.1404099,-527.140408,-527.140406,-527.1404041,-527.1404021,-527.1404001,-527.140398,-527.140396,-527.1403939,-527.1403918,-527.1403897,-527.1403876,-527.1403856,-527.1403835,-527.1403856,-527.1403877,-527.1403898,-527.1403919,-527.140394,-527.140396,-527.1403981,-527.1404001,-527.1404021,-527.1404041,-527.1404061,-527.1404081,-527.14041,-527.1404119,-527.1404137,-527.1404155,-527.1404173,-527.140419,-527.1404207,-527.1404224,-527.140424,-527.1404255,-527.140427,-527.1404285,-527.1404298,-527.1404312,-527.1404325,-527.1404337,-527.1404348,-527.1404359,-527.140437,-527.1404379,-527.1404388,-527.1404397,-527.1404404,-527.1404411,-527.1404417,-527.1404423,-527.1404428,-527.1404432,-527.1404435,-527.1404438,-527.1404439,-527.1404441,-527.1404441]]
        const layout = {
            margin : { t:0,b:0,l:0,r:0}
        }
        Plotly.newPlot("graph1",
            [{
                "type" : "scatter",
                "mode" : "markers+lines",
                x : data[1],
                y : data[2],
            }], layout
        )

        Plotly.newPlot("graph2",
            [{
                "type" : "scatter3d",
                "mode" : "markers+lines",
                x : data[0],
                y : data[1],
                z : data[2],
            }],layout
        )

    </script>
</body>
</html>

Screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions