Skip to content

Commit

Permalink
fix streamplot scalings
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Dec 8, 2023
1 parent 94fb069 commit 4d4f41a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoVista = "646e1f28-b900-46d7-9d87-d554eb38a413"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"

[compat]
CairoMakie = "0.11.3"
ColorSchemes = "3"
Expand Down Expand Up @@ -56,3 +49,10 @@ GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoVista = "646e1f28-b900-46d7-9d87-d554eb38a413"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"

[weakdeps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PlutoVista = "646e1f28-b900-46d7-9d87-d554eb38a413"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
4 changes: 3 additions & 1 deletion src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,13 @@ function vectorsample(grid::ExtendableGrid{Tv, Ti}, v;
for idim = 1:dim
ijkmax[idim] = ceil(Int64, (cminmax[idim][2] - offset[idim]) / spacing[idim]) + 1
end

@show ijkmax
@show spacing
# The ijk raster corresponds to a tensorproduct grid
# spanned by x,y and z coordinate vectors. Here, we build them
# in order to avoid to calculate them from the raster indices
rastercoord = [zeros(Float32, ijkmax[idim]) for idim = 1:dim]

for idim = 1:dim
rastercoord[idim] = collect(range(offset[idim]; step = spacing[idim],
length = ijkmax[idim]))
Expand Down
5 changes: 3 additions & 2 deletions src/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ function default_plot_kwargs()
:levelalpha => Pair(0.25, "3D isolevel alpha"),
:planealpha => Pair(0.25, "3D plane section alpha"),
:tetxplane_tol => Pair(0.0, "tolerance for tet-plane intersection in 3D"),
:spacing => Pair(:default, "Spacing of quiver points in vector plot"),
:spacing => Pair(:default,
"Spacing of quiver/streamplot interpolation points in vector plot"),
:offset => Pair(:default, "Offset of quiver grid"),
:vscale => Pair(1.0, "Vector field scale for quiver grid"),
:vconstant => Pair(false, "Set all arrow length constant in vector plot"),
Expand All @@ -334,7 +335,7 @@ function default_plot_kwargs()
:yplanes => Pair([prevfloat(Inf)], "3D y plane positions or number thereof"),
:zplanes => Pair([prevfloat(Inf)], "3D z plane positions or number thereof"),
:zoom => Pair(1.0, "Zoom level"),
:gridscale => Pair(1, "grid scale factor"),
:gridscale => Pair(1, "Grid scale factor. Will be applied also to planes, spacing."),
:azim => Pair(-60, "3D azimuth angle (in degrees)"),
:elev => Pair(30, "3D elevation angle (in degrees)"),
:perspectiveness => Pair(0.25,
Expand Down
2 changes: 1 addition & 1 deletion src/pyplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ function streamplot!(ctx, TP::Type{PyPlotType}, ::Type{Val{2}}, grid, func)

rc, rv = vectorsample(grid, func; spacing = ctx[:spacing], offset = ctx[:offset], xlimits = ctx[:xlimits],
ylimits = ctx[:ylimits], gridscale = ctx[:gridscale])
@show rv

X, Y = meshgrid(rc)

ax.streamplot(X, Y, rv[1, :, :, 1]', rv[2, :, :, 1]'; color = ctx[:color], density = 1)
Expand Down

0 comments on commit 4d4f41a

Please sign in to comment.