Note: I'm not sure if this is right repo, so feel free to move this issue.
I've been making some demos for my class on the PDE stability analysis content and found it helpful to make plot recipes so that I can reuse and tweak the plotting code. I've known about PlotRecipes.jl but just now invested enough time in learning them to really see the value. For example the following recipe reproduces the plot
@userplot EvalsPlot
@recipe function f(cp::EvalsPlot)
operator, = cp.args
λ = eigvals(operator)
seriestype --> :scatter
markershape --> :circle
legend --> :topleft
aspect_ratio --> 1
xlabel --> "Re ζ"
ylabel --> "Im ζ"
title --> "Eigenvalues of Operator"
framestyle --> :zerolines
real(λ),imag(λ)
end
x,Dₓ,Dₓₓ = FNC.diffper(40,[0,1]);
plt = plot()
for ϵ in [0.001 0.01 0.05]
evalsplot!(plt, -Dₓ + ϵ*Dₓₓ, label="\\epsilon = $ϵ")
end
plt
By making a recipe, you can use evalsplot and evalsplot! with all of kwargs that bare plot and plot! support. These recipes would be reusable exports from this library.
I wasn't sold, until I figured out how to make nested layouts in a single recipe. For the advection-diffusion case you have complex eigenvectors so in order to visualize their expansion in the eigenbasis, I want to show the magnitude and argument of the complex projections separately.
This code makes the side by side part of the following plot, which is then stacked with another recipe.

@userplot FourierPlot
@recipe function f(cp::FourierPlot)
y = cp.args[1]
r = abs.(y)
phase = complex2deg.(y)
layout := @layout [abs phase]
@series begin
seriestype := scatter
subplot := 1
title --> "abs(Fourier Expansion)"
xlabel --> "index"
ylabel --> "\$abs(v_i^Tu)\$"
1:length(r), r
end
large_index = r .> 1e-1
phase = phase[large_index]
@series begin
seriestype := scatter
subplot := 2
title --> "angle(Fourier Expansion)"
xlabel --> "index"
ylabel --> "\$angle(v_i^Tu)\$"
xlims --> (1, length(r))
findall(large_index), phase
end
end
stackplot(p1,p2) = plot(p1,p2, layout=@layout [a;b])
Note: I'm not sure if this is right repo, so feel free to move this issue.
I've been making some demos for my class on the PDE stability analysis content and found it helpful to make plot recipes so that I can reuse and tweak the plotting code. I've known about PlotRecipes.jl but just now invested enough time in learning them to really see the value. For example the following recipe reproduces the plot
By making a recipe, you can use
evalsplotandevalsplot!with all of kwargs that bareplotandplot!support. These recipes would be reusable exports from this library.I wasn't sold, until I figured out how to make nested layouts in a single recipe. For the advection-diffusion case you have complex eigenvectors so in order to visualize their expansion in the eigenbasis, I want to show the magnitude and argument of the complex projections separately.
This code makes the side by side part of the following plot, which is then stacked with another recipe.