Cones Size problem in loops

Hi everyone,

We have spoken about size of cones (Cones Size Problem - #2 by Bijan) But there is a problem when we use many cones in a command (fig.add_cone). For better understanding take a look to the below codes:

import plotly.graph_objects as go
import plotly as plt
import numpy as np
import random as rnd

def rndata():
    a=0
    b=10
    n=1
    rslt=[]
    for i in range(n):
        rslt.extend([rnd.randint(a,b),rnd.randint(a,b),None])
    return rslt

fig = go.Figure()

u,v,w=[],[],[]
xx,yy,zz=[],[],[]


for i in range(10):
    x= rndata()
    y=rndata()
    z=rndata()

    size=((x[1]-x[0])**2+(y[1]-y[0])**2+(z[1]-z[0])**2)**0.5
    axis=[(x[1]-x[0])/size,(y[1]-y[0])/size,(z[1]-z[0])/size]

    fig.add_scatter3d(x=x,y=y,z=z,mode="lines")

    u.extend([axis[0],None])
    v.extend([axis[1],None])
    w.extend([axis[2],None])
    xx.extend([x[1],None])
    yy.extend([y[1],None])
    zz.extend([z[1],None])

sizes=rnd.randint(1,5)
fig = fig.add_cone( opacity=0.5, sizemode='absolute',sizeref=sizes,showscale=False,
                                 colorscale=[cl,cl],
                                 anchor='tip', #['tip', 'tail', 'cm', 'center']
    x=xx, y=yy, z=zz, u=u,  v=v,  w=w,
    text=str(sizes))

fig.update_layout(scene_aspectmode='data',)

fig.show()

When we run above code it doesn’t return correct sizes of cones (check it by running multiple times) but when we run the codes in ( Cones Size Problem - :bar_chart: Plotly Python - Plotly Community Forum) sizes are correct. Is it a bug or there is a solution?

The problem has solved according to this GitHub link: Cone Size

Here is a code for sample:

import plotly.graph_objects as go
import random as rnd
import math

fig = go.Figure()

u=[]
v=[]
w=[]
xx=[]
yy=[]
zz=[]

for i in range(20):
    
    u0=1
    v0=rnd.randint(0,2)
    w0=rnd.randint(0,2)
    
    r = math.sqrt(u0*u0+v0*v0+w0*w0)
    u0 /= r
    v0 /= r
    w0 /= r 
    
    u.extend([u0,None])
    v.extend([v0,None])
    w.extend([w0,None])
    xx.extend([rnd.randint(0,50),None])
    yy.extend([rnd.randint(0,50),None])
    zz.extend([rnd.randint(0,50),None])

sizes=5  
fig = fig.add_cone(sizemode='raw',sizeref=sizes, colorscale=['red','red'],
                   x=xx, y=yy, z=zz, u=u, v=v, w=w,)
fig.show()

The result are cones with the same size. Pay attention that β€˜raw’ option is not available in older version of Plotly and above code has been written and executed using Plotly version: 5.22.0