Skip to content

Commit

Permalink
update basic Plots and Makie recipes
Browse files Browse the repository at this point in the history
Former-commit-id: ee63f6c
  • Loading branch information
gaelforget committed Feb 21, 2021
1 parent 5ba572e commit 29fc7c1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
21 changes: 19 additions & 2 deletions examples/recipes_makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@
using Random, Makie, MeshArrays, DataFrames, ColorSchemes, Statistics

"""
PlotMakie(df::DataFrame,nn::Integer)
plot(𝐼::Individuals)
Plot the initial and final positions as scatter plot in x,y plane.
"""
function plot(𝐼::Individuals)
🔴_by_t = groupby(𝐼.🔴, :t)
if sum(names(🔴_by_t).=="lon")==0
fig, ax, _ = scatter(🔴_by_t[1].x,🔴_by_t[1].y,color=:red,markersize=:2,linewidth=0.)
scatter!(🔴_by_t[end].x,🔴_by_t[end].y,color=:blue,markersize=:2,linewidth=0.)
else
fig, ax, _ = scatter(🔴_by_t[1].lon,🔴_by_t[1].lat,color=:red,markersize=:2)
scatter!(🔴_by_t[end].lon,🔴_by_t[end].lat,color=:blue,markersize=:2)
end
return fig
end

"""
plot_paths(df::DataFrame,nn::Integer)
Plot random subset of size nn trajectories.
"""
function PlotMakie(df::DataFrame,nn::Integer,dMax::Float64=0.)
function plot_paths(df::DataFrame,nn::Integer,dMax::Float64=0.)
IDs = randperm(maximum(df.ID))
COs=[:gray76 :gold :limegreen :black]

Expand Down
10 changes: 8 additions & 2 deletions examples/recipes_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ Plot the initial and final positions as scatter plot in x,y plane.
"""
function plot(𝐼::Individuals)
🔴_by_t = groupby(𝐼.🔴, :t)
scatter(🔴_by_t[1].x,🔴_by_t[1].y,c=:red,label="t0",marker = (:circle, stroke(0)))
scatter!(🔴_by_t[end].x,🔴_by_t[end].y,c=:blue,label="t1",marker = (:circle, stroke(0)))
if (sum(names(🔴_by_t).=="lon")==0)
fig=scatter(🔴_by_t[1].x,🔴_by_t[1].y,c=:red,label="t0",marker = (:circle, stroke(0)))
scatter!(🔴_by_t[end].x,🔴_by_t[end].y,c=:blue,label="t1",marker = (:circle, stroke(0)))
else
fig=scatter(🔴_by_t[1].lon,🔴_by_t[1].lat,c=:red,label="t0",marker = (:circle, stroke(0)))
scatter!(🔴_by_t[end].lon,🔴_by_t[end].lat,c=:blue,label="t1",marker = (:circle, stroke(0)))
end
return fig
end

"""
Expand Down
3 changes: 2 additions & 1 deletion examples/worldwide/three_dimensional_ocean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ df=DataFrame(:z => fill(kk,nf),:f => fill(1,nf))
#
# ```
# include(joinpath(p,"../examples/recipes_Makie.jl"))
# p=PlotMakie(𝐼.🔴,100,180.);
# #p=plot(𝐼)
# p=plot_paths(𝐼.🔴,100,180.);
# display(p)
# ```

Expand Down

0 comments on commit 29fc7c1

Please sign in to comment.