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

Proposes a 3D quiver #3134

Merged
merged 12 commits into from
Nov 13, 2020
Merged

Proposes a 3D quiver #3134

merged 12 commits into from
Nov 13, 2020

Conversation

kellertuer
Copy link
Contributor

@kellertuer kellertuer commented Nov 10, 2020

This PR introduces a quiver functionality (at least partially, see below) for 3D quivers, cf. #319.

This extension can be seen by looking at

using Plots
x = [1.0, 2.0, 3.0]
y = [0.0, 1.0, 0.0]
z = [1.0, 0.0, 0.0]
u = [1.0, 1.0, 1.0]
v = [0.5, 0.5, 0.5]
w = [0.0, 0.0, 1.0]
s = quiver(x,y,z, quiver=(u,v,w))

which was previously a little strange (took x and z but u and w, first and last quiver component)
pre

and now it correctly looks like
post

Works/tested with

  • GR
  • PyPlot

Questions

  • What would be the best way to hack an arrow in 3D to make it work e.g. with Plotly?
  • Which tests are required here?

@BeastyBlacksmith
Copy link
Member

That is a really good addition. I don't know about plotly, but as a test it would be sufficient to add an example at the end of the examples array here https://github.com/JuliaPlots/Plots.jl/blob/master/src/examples.jl, add the number to the excludes of the backends where it doesn't work and then do a PR against PlotReferenceImages to add the reference image for the GR backend.

@kellertuer
Copy link
Contributor Author

Thanks, I have to check how one can add things to that list, but then I'll do that for sure.

jheinen and others added 8 commits November 13, 2020 08:38
* add linestyle to contour plots

* Update precompile_*.jl file (JuliaPlots#3140)

Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: BeastyBlacksmith <BeastyBlacksmith@users.noreply.github.com>
@kellertuer
Copy link
Contributor Author

Uh, nice! I was just starting to test and got lost in GR arrow head sizes and (maybe) missing scaling of quivers, when I wanted to add a 2D example (found a bug in my code, too). Will update/merge that here, then.

@daschw
Copy link
Member

daschw commented Nov 13, 2020

I'm sorry about that commit mess above. I added a new test example. I hope that's fine.

using Plots

ϕs = range(-π, π, length=50)
θs = range(0, π, length=25)
θqs = range(1, π-1, length=25)

x = vec([sin(θ) * cos(ϕ) for (ϕ, θ) in Iterators.product(ϕs, θs)])
y = vec([sin(θ) * sin(ϕ) for (ϕ, θ) in Iterators.product(ϕs, θs)])
z = vec([cos(θ) for (ϕ, θ) in Iterators.product(ϕs, θs)])

u = 0.1 * vec([sin(θ) * cos(ϕ) for (ϕ, θ) in Iterators.product(ϕs, θqs)])
v = 0.1 * vec([sin(θ) * sin(ϕ) for (ϕ, θ) in Iterators.product(ϕs, θqs)])
w = 0.1 * vec([cos(θ) for (ϕ, θ) in Iterators.product(ϕs, θqs)])

quiver(x,y,z, quiver=(u,v,w))

quiver3

@kellertuer
Copy link
Contributor Author

oh, what a neat example!

@kellertuer
Copy link
Contributor Author

I was thinking about adding a 2D quiver example, too, but got lost since this

using Plots
xr = range(-π, π, length=41)
yr = range(-π, π, length=41)

X = vec([ x for x ∈ xr, y ∈ yr])
Y = vec([ y for x ∈ xr, y ∈ yr])
U = vec([ 0.12*sin(x)*cos(y) for x ∈ xr, y ∈ yr])
V = vec([ 0.12*cos(x)*sin(y) for x ∈ xr, y ∈ yr])

s = quiver(X, Y, quiver=(U,V))

has huge arrowheads in GR.
And maybe for another PR one could also introduce an auto-down/up-scaling option of the vectors (I think both peplos and Matlab do this)

@daschw
Copy link
Member

daschw commented Nov 13, 2020

I think we can also investigate the arrowhead size issue and the 2D example in another issue/PR.

@daschw
Copy link
Member

daschw commented Nov 13, 2020

I like the auto-scaling idea.

@kellertuer
Copy link
Contributor Author

Ok, sure.
For auto-scaling I have an idea, I will think about it and propose something maybe next week – something along the lines of „scale down to the longest vector being as long as the smallest distance of domain points.“

@daschw daschw merged commit 5861b1f into JuliaPlots:master Nov 13, 2020
@daschw
Copy link
Member

daschw commented Nov 13, 2020

Thanks for your contribution @kellertuer !

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

Successfully merging this pull request may close these issues.

5 participants