-
-
Notifications
You must be signed in to change notification settings - Fork 364
[FR] CommonPlot interface #5057
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
Comments
We already have that in RecipesBase Plots.jl/RecipesBase/src/RecipesBase.jl Line 26 in 29a8007
However, if you just want that to avoid naming conflicts, its not really an interface. If your |
Thank you for your answer. Actually "interface" is not the right word. I just want to extend the I have added this to my code: function RecipesBase.plot(sol::AbstractSolution; kwargs...)
throw(CTBase.ExtensionError(:Plots))
end
function RecipesBase.plot!(p::RecipesBase.AbstractPlot, sol::AbstractSolution; kwargs...)
throw(CTBase.ExtensionError(:Plots))
end which is then extended in the extension when Plots is imported. At the end, to plot an optimal control solution ( function Plots.plot!(
p::Plots.Plot,
sol::CTModels.Solution;
layout::Symbol=__plot_layout(),
control::Symbol=__control_layout(),
time::Symbol=__time_normalization(),
solution_label::String="",
state_style=(),
control_style=(),
costate_style=(),
kwargs...,
)
...
end
function Plots.plot(
sol::CTModels.Solution;
layout::Symbol=__plot_layout(),
control::Symbol=__control_layout(),
time::Symbol=__time_normalization(),
size=__size_plot(sol, control),
solution_label::String="",
state_style=(),
control_style=(),
costate_style=(),
kwargs...,
)
...
end |
I'd say you should also define methods for Does this work for you? And if not what is the error? |
It would be nice to have a CommonPlot.jl package as CommonSolve.jl where
plot
andplot!
are defined (maybe others too). Then, theplot
andplot!
from Plots would have to extend those from CommonPlot.It would be possible to define in any other ecosystem a
plot
function without ambiguity with Plots. Besides, it would make possible to have Plots.jl as an extension withplot
extended twice, first in the main module to return a message like "please make: julia> using Plots" and secondly in the extension.The text was updated successfully, but these errors were encountered: