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

No check for equal proportions in plot #10

Open
bart1 opened this issue Mar 7, 2022 · 5 comments
Open

No check for equal proportions in plot #10

bart1 opened this issue Mar 7, 2022 · 5 comments
Assignees

Comments

@bart1
Copy link

bart1 commented Mar 7, 2022

I just encountered this case, it seems geom_quiver does not check if the dimensions are equal between X and Y. This causes a problem that the directions of the arrows do not correct. This is easily fixable by using coord_equal or coord_fixed but it might be good to warn users to do so. Maybe it can be checked if the coord inherits CoordFixed, maybe a check for the ratio would also be good? (The first plot is incorrect)

d<-data.frame(t=Sys.time()+(3600*1:4), x=1000*c(1,-1), y=1000*c(1,1,-1,-1))
require(ggplot2)
#> Loading required package: ggplot2
require(ggquiver)
#> Loading required package: ggquiver
ggplot(d)+geom_quiver(aes(x=t, y=0, u=y,v=x))

ggplot(d)+geom_quiver(aes(x=t, y=0, u=y,v=x))+coord_equal()

Created on 2022-03-07 by the reprex package (v2.0.1)

@mitchelloharawild mitchelloharawild self-assigned this Mar 7, 2022
@mitchelloharawild
Copy link
Owner

Perhaps I'm missing something here, but is there a general requirement for the coordinates to be fixed? The arrows point to the same location in both plots, but have different angles when the plot's aspect ratio changes. I think this behaviour is expected when working with u and v as force offsets from the starting position.

It is definitely worth mentioning that when the arrow's angles are important, that using equal coordinate ratios for x and y axis is needed.

@mitchelloharawild
Copy link
Owner

Thanks for the reprex and clear explanation by the way! 🎉

@bart1
Copy link
Author

bart1 commented Mar 8, 2022

No problem, maybe it is not the case for all applications, for most applications I could see for the arrows the direction does matter. I encountered this when a student had some code where the arrows were pointing in a "wrong" direction. In our case it was a time series of vectors. As I know the u and v notation mostly from wind fields there the direction is important. I would say you know better how it is used and may see what the most common applications are.

@mitchelloharawild
Copy link
Owner

For wind fields, I imagine it will be plotted on a map which would use the appropriate map coordinates. Perhaps I could add a message when the default ggplot2 coordinate space is used with geom_quiver(), suggesting that the angles may not be what is expected unless coord_equal() is used.

@bart1
Copy link
Author

bart1 commented Mar 9, 2022

In this case we were interested in a timeseries of wind to that is why the map did not have dimensions. I think that warning/message sounds sensible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants