Skip to content

Commit ae6a516

Browse files
authored
imshow -> pcolormesh in Jacobian plots (#15)
1 parent 20da5c5 commit ae6a516

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Peaks = "0.4.0"
4040
PyCall = "1.93.0"
4141
PyPlot = "2.10.0"
4242
SymbolicUtils = "0.19.7"
43-
Symbolics = "4.3.0"
43+
Symbolics = "4.3.1"
4444
julia = "1.7.0"
4545

4646
[extras]

src/modules/LinearResponse/jacobian_spectrum.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ end
120120
Ω_range,
121121
branch::Int,
122122
y_offset::String="0.0",
123-
y_center::Float64=0.0,
124123
x_scale=1.0,
125124
y_scale=1.0,
126125
logscale=false)
@@ -130,7 +129,7 @@ Performs one matrix diagonalization for each element of `Ω_range`.
130129
This method is faster than `plot_response` but results in errors where the noise frequency
131130
is far from the frequency of the harmonic variables.
132131
"""
133-
function plot_jacobian_spectrum(res::Result, nat_var::Num; Ω_range, branch::Int, y_offset::String="0.0", y_center::Float64=0.0, x_scale=1.0, y_scale=1.0, logscale=false)
132+
function plot_jacobian_spectrum(res::Result, nat_var::Num; Ω_range, branch::Int, y_offset::String="0.0", x_scale=1.0, y_scale=1.0, logscale=false)
134133

135134

136135
length(size(res.solutions)) != 1 && error("1D plots of not-1D datasets are usually a bad idea.")
@@ -140,19 +139,20 @@ function plot_jacobian_spectrum(res::Result, nat_var::Num; Ω_range, branch::Int
140139
X = Vector{Float64}(collect(values(res.swept_parameters))[1][stability])
141140

142141
offset = Vector{Float64}(getindex.(transform_solutions(res, y_offset), branch))[stability]
143-
142+
144143
# only get spectra of the stable points!
145144
spectra = [JacobianSpectrum(res, branch=branch, index = i) for i in (1:length(res.solutions))[stability]]
146-
Y = Array{Float64, 2}(undef, length(Ω_range), length(X))
145+
C = Array{Float64, 2}(undef, length(Ω_range)-1, length(X)-1)
147146

148-
for ij in CartesianIndices(Y)
149-
Y[ij] = abs(evaluate(spectra[ij[2]][nat_var], reverse(Ω_range)[ij[1]] - (y_center-offset[ij[2]])))
147+
for ij in CartesianIndices(C)
148+
C[ij] = abs(evaluate(spectra[ij[2]][nat_var], Ω_range[ij[1]] - offset[ij[2]]))
150149
end
151-
X = x_scale .* X
152-
Y = logscale ? log.(Y) : Y
153-
Ω_range, y_center = y_scale .* Ω_range, y_scale * y_center
154-
plt = PyPlot.imshow(Y, aspect="auto", extent=[X[1], X[end], Ω_range[1]-y_center, Ω_range[end]-y_center])
150+
x_mat = x_scale * hcat([x*ones(length(Ω_range)) for x in X]...)
151+
y_mat = y_scale * hcat([Ω_range for j=1:length(X)]...)
152+
C = logscale ? log.(C) : C
153+
154+
PyPlot.pcolormesh(x_mat, y_mat, C)
155155
xlabel(Latexify.latexify(string(first(keys(res.swept_parameters)))));
156-
ylabel("noise angular frequency - " * y_offset);
157-
return plt
156+
ylabel("noise angular frequency - " * latexify(y_offset));
157+
return C
158158
end

0 commit comments

Comments
 (0)