Black Lives Matter. Please consider donating to Black Girls Code today.

3D Vector Arrows

Hi there,

I am trying to create a 3D chart with a surface representing the topology of a certain location.
At this location I am going to have a sensor that measures the gravitational forces in three axes, x y z.

With this I want to create an arrow from the physical location of the sensor on the surface (eg. [10, 10, 100]), pointing towards the point made by the values I get from my sensor (eg. [20, 19, 169]).

Is this in any way possible with Plotly? I have found that I can make almost exactly what I want with markers, but in 3D the markes don’t support the arrow shape. I can make a line with two crosses in each end, but making a plain arrow seems to not be possible with this solution.

Another way I have found to make arrows, is to use the annotations. The problem here however is that the arrow is more or less stationary and not changing its angle depending on the view.

Any solution or nudge in the right direction would be greatly appreciated :slight_smile:

Hey @xzyph

Whilst it isn’t 3D arrows, perhaps this may be of interest to you https://twitter.com/plotlygraphs/status/1006554226548494336 and docs here https://plot.ly/python/3d-cone/

1 Like

I very much appreciate your suggestion and I’ve been trying to add it to my code.
When adding go.Cone() to the data variable, I end up with the error that plotly.graph_objs doesn’t contain the attribute ‘Cone’, even though I do exactly as the reference instructs (https://plot.ly/python/reference/#cone)

I realize that this might be because I am using a 2D cone, so I try to add the cone into the data variable as
{ 'type': 'cone', 'x': [1], 'y': [1], 'z': [1], 'u': [1], 'v': [1], 'w': [0] }

This however results in this error:

It’s invalid because it doesn’t contain a valid ‘type’ value.

Do you perhaps know what I am missing to attach the cone figure to my surface figure?

I see! Looks like the plotly.graph_objs needs updated on Plotly’s end. In the interim, with version 2.7.0 you can use this method below instead of go.Cone. Note the use of validate=False

import plotly.plotly as py

data = [{
    'type': 'cone',
    'x': [1], 'y': [1], 'z': [1],
    'u': [1], 'v': [1], 'w': [0]
}]

layout = {
    'scene': {
      'camera': {
        'eye': {'x': -0.76, 'y': 1.8, 'z': 0.92}
      }
    }
}

fig = {"data": data, "layout": layout}
py.iplot(fig, filename='cone-basic', validate=False)
1 Like

The validate=False did the trick!

Thank you very much @bcd