From 1e04fe0dc334cfa9ce4593cf41ef5abeabcb8735 Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Tue, 9 Jul 2024 07:26:54 +0800 Subject: [PATCH] Clean up docs --- src/plot/pyplot.jl | 20 ++++++++++---------- src/plot/utility.jl | 12 +++++++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/plot/pyplot.jl b/src/plot/pyplot.jl index 3bbbdcd..6a02b2e 100644 --- a/src/plot/pyplot.jl +++ b/src/plot/pyplot.jl @@ -55,15 +55,16 @@ end """ - plotdata(data, func, args, kwargs...) + plotdata(bd, func, args, kwargs...) Plot the variable from SWMF output. -`plotdata(data, "p", plotmode="contbar")` +# Examples +`plotdata(bd, "p", plotmode="contbar")` -`plotdata(data, "p", plotmode="grid")` +`plotdata(bd, "p", plotmode="grid")` -`plotdata(data, func, plotmode="trimesh", plotrange=[-1.0, 1.0, -1.0, 1.0], plotinterval=0.2)` +`plotdata(bd, func, plotmode="trimesh", plotrange=[-1.0, 1.0, -1.0, 1.0], plotinterval=0.2)` # Arguments - `bd::BATLData`: BATSRUS data. @@ -317,13 +318,12 @@ end """ - cutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1, - levels=20) + cutplot(data, var, ax=nothing; plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1) -2D plane cut contourf of 3D box data. +2D plane cut pcolormesh of 3D box data. `sequence` is the index along `dir`. """ function cutplot(bd::BATLData, var::AbstractString, ax=nothing; - plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1, levels::Int=20) + plotrange=[-Inf,Inf,-Inf,Inf], dir="x", sequence=1) x, w = bd.x, bd.w varIndex_ = findindex(bd, var) @@ -349,7 +349,7 @@ function cutplot(bd::BATLData, var::AbstractString, ax=nothing; cut1, cut2, W = subsurface(cut1, cut2, W, plotrange) end if isnothing(ax) ax = plt.gca() end - c = ax.contourf(cut1, cut2, W, levels) + c = ax.pcolormesh(cut1, cut2, W) title(bd.head.wnames[varIndex_]) @@ -473,7 +473,7 @@ end contourf(data, var, ax=nothing; levels=0, plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1, innermask=false, kwargs...) -Wrapper over `contourf` in matplotlib. +Wrapper over `contourf` in matplotlib. See [`getdata2d`](@ref) for some related keywords. """ function PyPlot.contourf(bd::BATLData, var::AbstractString, ax=nothing; levels::Int=0, plotrange=[-Inf,Inf,-Inf,Inf], plotinterval=0.1, innermask=false, kwargs...) diff --git a/src/plot/utility.jl b/src/plot/utility.jl index 225b5cf..780977b 100644 --- a/src/plot/utility.jl +++ b/src/plot/utility.jl @@ -2,13 +2,15 @@ """ getdata2d(bd::BATLData, var::AbstractString, plotrange=[-Inf, Inf, -Inf, Inf], - plotinterval=Inf; innermask=false, rbody=1.0) + plotinterval=Inf; kwargs...) Return 2D slices of data `var` from `bd`. If `plotrange` is not set, output data resolution -is the same as the original. If `innermask==true`, then the inner boundary cells are set to -NaN. If `innermask == true` but the rbody parameter is not found in the header, we use the -keyword `rbody` as the inner radius. If `useMatplotlib==false`, a native Julia scattered -interpolation is used (but is somehow slower than Matplotlib). +is the same as the original. + +# Keyword Arguments +- `innermask=false`: Whether to mask the inner boundary with NaN. +- `rbody=1.0`: Radius of the inner mask. Used when the rbody parameter is not found in the header. +- `useMatplotlib=true`: Whether to Matplotlib (somehow faster) or NaturalNeighbours for scattered interpolation. """ function getdata2d(bd::BATLData, var::AbstractString, plotrange::Vector=[-Inf, Inf, -Inf, Inf], plotinterval::Real=Inf;