plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.38k stars 2.56k forks source link

add fixed size for arrow heads in Quiver Plot #1511

Open gurpreet3737 opened 5 years ago

gurpreet3737 commented 5 years ago

While plotting two or more vectors using quiver plots arrows heads are scaled with respect to barb length. No option for having arrow heads of fixed size as depicted in attached file. Please add option for the same.Here is the code:

from plotly import tools from plotly.offline import download_plotlyjs, plot, iplot, init_notebook_mode import plotly.graph_objs as go import plotly.figure_factory as ff import numpy as np

init_notebook_mode(connected=True)

layout=go.Layout(xaxis=dict(range=[-10,10],dtick=1), yaxis=dict(range=[-10,10],dtick=1, ticks='outside'), width=900, height=900)

v=np.array([[1,1],[-2,2], [4,7]]) x, y = [0,0,0], [0,0,0] fig= ff.create_quiver(x, y, v[:,0], v[:,1], scale=1) fig.layout.update(layout) iplot(fig) vector

janosh commented 3 years ago

Would unit-vectoring and then multiplying the barbs end_x and end_y each by sqrt(fixed_size) in get_barbs be an acceptable implementation?

https://github.com/plotly/plotly.py/blob/ce0ed07d872c487698bde9d52e1f1aadf17aa65f/packages/python/plotly/plotly/figure_factory/_quiver.py#L177-L197