Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fixed size for arrow heads in Quiver Plot #1511

Open
gurpreet3737 opened this issue Apr 10, 2019 · 1 comment
Open

add fixed size for arrow heads in Quiver Plot #1511

gurpreet3737 opened this issue Apr 10, 2019 · 1 comment
Labels
feature something new P3 backlog

Comments

@gurpreet3737
Copy link

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

@gurpreet3737 gurpreet3737 changed the title No fixed size for arrow heads No fixed size for arrow heads in Quiver Plot Apr 10, 2019
@janosh
Copy link
Contributor

janosh commented Oct 6, 2021

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?

def get_barbs(self):
"""
Creates x and y startpoint and endpoint pairs
After finding the endpoint of each barb this zips startpoint and
endpoint pairs to create 2 lists: x_values for barbs and y values
for barbs
:rtype: (list, list) barb_x, barb_y: list of startpoint and endpoint
x_value pairs separated by a None to create the barb of the arrow,
and list of startpoint and endpoint y_value pairs separated by a
None to create the barb of the arrow.
"""
self.end_x = [i + j for i, j in zip(self.x, self.u)]
self.end_y = [i + j for i, j in zip(self.y, self.v)]
empty = [None] * len(self.x)
barb_x = utils.flatten(zip(self.x, self.end_x, empty))
barb_y = utils.flatten(zip(self.y, self.end_y, empty))
return barb_x, barb_y

@gvwilson gvwilson self-assigned this Jun 13, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added feature something new P3 backlog and removed figure_factory labels Aug 12, 2024
@gvwilson gvwilson changed the title No fixed size for arrow heads in Quiver Plot add fixed size for arrow heads in Quiver Plot Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

5 participants