-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
The length of the arrows are not maintained by the 2D quiver plot in figure factory. #1187
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
Comments
Fun fact, the plotly.js team was working actively on a 3D quiver plot (see closed issue #861) earlier this year. This issue maybe a good time for the plotly community to give a little love to their 2D quiver plot. Just saying ;) |
Hi @dabana , Thanks for the report, this is a great point regarding scale distortion. What if we added Do you have any interest in working on this? |
Hi Jon, Yes I am interested in working on this. I will submit a pull request once I have a proper fix figured out. The addition of It would be nice if we could "read" the scale ratio out of the final figure and then apply the inverse transform on the axis, no new input parameter needed. Any idea how to do this? |
Yeah, I was picturing that the user would use the Another option that comes to mind is that the user could specify the figure width/height that they want. Then we could subtract off the margins to get the pixel width/height of the axis extents. Then we could also manually compute the axis range extents based on the data itself to compute the To go a step further, we could add an option to return the figure as a |
I like the callback function approach a lot. I will look into it. Thanks! |
I have opened a pull request regarding only the scaling of the arrows for now by passing a I have not worked on the widget callback option yet. I still have problems making widgets work on my dev environment. Here is the result with |
@jonmmease I am having trouble making the FigureWidget callback example work. I get a 404 reponse when I run the following cell for the first time
Then nothing and the plot does not show. This is the error
Maybe there is something I do wrong... |
Hi @dabana , could you try upgrading plotly and all of the other packages to match the current versions in the README instructions and try again? |
Let's close this issue as your initial solution was merged and included in version 3.3.0. Why don't you open a new issue to discuss the |
Bug report
Thanks to the Plotly community for this great implementation of 2D quiver plots in the figure factory. The issue is that the length of the arrows are not maintained by the quiver plot.
Bug summary
The length of the arrows in a quiver plot carries relevant information in most applications (wind speed, force field intensity, etc.). This seem to be the case with the quiver plot in figure factory if both axis have the same scale (for example if quiver plot is plotted on a map: x and y coordinates have obviously the same scale). However, as soon as the scales of both axis are different, the apparent length of the arrows is distorted. The barb angle is also affected. This should not be the case.
Code for reproduction
This is an instance of a quiver plot where the scales of both axis are different but where the length of each arrow is intended to be the same (using the norm and an angle to produce u an v).
Actual outcome
The above code produces arrows with apparent lengths changing depending on their angle. This should not be the case.
Expected outcome
This is an instance of the above quiver plot but where the scales of both axis are forced to be the same using specifications on the layout.
It would be nice to have nicely scaled arrows as the above plot but with axis of different scales.
WORKAROUND: To maintain an aspect ratio similar the original plot, we can force a scale ratio different than 1 and apply an inverse transformation on u (or v) to counter the effect of the stretching.
This workaround is not perfect though. Despite the fact that the length of the arrows are maintained, the barbs of the arrows are still distorted and they don't look good.
Plotly version
plotly installed from pip
The text was updated successfully, but these errors were encountered: