Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Computer Modern" not global default font #50

Closed
wants to merge 2 commits into from
Closed

"Computer Modern" not global default font #50

wants to merge 2 commits into from

Conversation

oameye
Copy link
Member

@oameye oameye commented Oct 3, 2022

The solution to issue #49:
HarmonicBalance does not define "Computer Modern" is the the global default font. Yet only the HarmonicBalance plot functions will use Computer modern by "default".

I tested the code with the Duffing oscillator example:

using HarmonicBalance
@variables α, ω, ω0, F, t, γ, x(t) # declare constant variables and a function x(t)
diff_eq = DifferentialEquation(d(x,t,2) + ω0^2*x + α*x^3 + γ*d(x,t) ~ F*cos*t), x) #declare differential equation
add_harmonic!(diff_eq, x, ω) # specify the ansatz x = u(T) cos(ωt) + v(T) sin(ωt)
harmonic_eq = get_harmonic_equations(diff_eq)
varied = ω => LinRange(0.9, 1.2, 100) # range of parameter values
fixed ==> 1., ω0 => 1.0, F => 0.01, γ=>0.01) # fixed parameters
solutions = get_steady_states(harmonic_eq, varied, fixed)
plot(solutions, x="ω", y="sqrt(u1^2 + v1^2)")
plot_phase_diagram(solutions)

x = -5:0.1:5
plot(x, x.^2)

yet only the HarmonicBalance plot functions will use Computer modern by "default"
@jkosata
Copy link
Member

jkosata commented Oct 3, 2022

This should work but the point of set_Plots_default was to avoid this duplicity scattered around and have everything in one place.

Could you try passing it via a Dict ? Instead of set_Plots_default, we could have a
_default_Plots = Dict([:tickfont => "Computer Modern", ...) etc.

Then prepending this to the plotting functions such as
plot(res, varargs... ; _default_Plots... , kwargs...) should do the trick. plot1D and plot2D receive it from plot afaik

This also needs to be added to TimeEvolution.plot

@oameye
Copy link
Member Author

oameye commented Oct 4, 2022

The default font is now implemented by a Dictionary, like you suggsted. It is again tested with the Duffing oscillator example (see above). I added the dictionary to all plot occurences I could find, e.g., in the modules.

@jkosata
Copy link
Member

jkosata commented Oct 4, 2022

Great, one more thing: within the modules (TimeEvolution, LinearResponse), you need to call HarmonicBalance._set_Plots_default to refer back to the main scope (now these won't plot).

reminds me we should have automated tests for plotting, even to see if the functions don't error :))

@oameye
Copy link
Member Author

oameye commented Oct 4, 2022

Ha yes rookie mistake. Will do it in the afternoon.

@jkosata jkosata mentioned this pull request Oct 6, 2022
@jkosata
Copy link
Member

jkosata commented Oct 6, 2022

Closed by #51

@jkosata jkosata closed this Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants