Replace PyPlot with Plots to remove unnecessary Python dep#84
Replace PyPlot with Plots to remove unnecessary Python dep#84
Conversation
These were testing with the default_optimization.jl core example.
|
Still need to re-implement the |
- Yticklabels on control deployment plots were not correctly displaying - Dollar sign not showing us with \$ in LaTeXStrings
|
@fonsp, I think I've now removed all traces of Python, PyCall, and PyPlot from the entire package! |
| using LaTeXStrings | ||
| using Plots.Measures | ||
|
|
||
| default(label="", grid=true, gridalpha=0.15) |
There was a problem hiding this comment.
This line, and line 1 (gr()) will also set the defaults for everything else the user wants to do outside of this package, which can be very confusing (running import ClimateMargo would suddenly show grids on all plots).
Instead, we can have function to create a "base plot":
create_baseplot() = plot(; label="", grid=true, gridalpha=0.15)...continued
| xlabel("year") | ||
| grid(true, alpha=0.3) | ||
| return | ||
| p = plot(title="net greenhouse gas emissions") |
There was a problem hiding this comment.
...continued
Which you can use here:
p = create_baseplot()
plot!(p, title="net greenhouse gas emissions")| ylim(ylims) | ||
| return | ||
| end | ||
| gr() |
There was a problem hiding this comment.
This is already the default for Plots.jl, so it's better to remove it here, and let the user change it if they want to by adding gr() in their notebook.
| return p | ||
| end | ||
|
|
||
| function plot_concentrations(m::ClimateModel) |
There was a problem hiding this comment.
You can change this into:
function plot_concentrations(m::ClimateModel; kwargs...)continued...
| plot!(p, ylabel=L"CO$_{2e}$ concentration [ppm]", xlabel="year") | ||
| plot!(p, xlim=(t(m)[1],2200.), ylim=ylims, xticks=t(m)[1]:40.:2200.) | ||
| plot!(p, legend=:topleft) | ||
| return p |
There was a problem hiding this comment.
...continued
And here, you allow the user to override any setting that they want:
return plot!(p; kwargs...)For example, this lets you do:
plot_concentrations(model; size=(100,100))to create a tiny concentrations plot 🐛
There was a problem hiding this comment.
Same for the other plotting methods

No description provided.