https://github.com/projecttorreypines/helpplots.jl
Print keywords arguments help for plot(...) function calls
https://github.com/projecttorreypines/helpplots.jl
Last synced: 4 months ago
JSON representation
Print keywords arguments help for plot(...) function calls
- Host: GitHub
- URL: https://github.com/projecttorreypines/helpplots.jl
- Owner: ProjectTorreyPines
- License: apache-2.0
- Created: 2025-02-27T19:50:47.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-11-24T13:18:44.000Z (7 months ago)
- Last Synced: 2025-12-16T13:22:23.254Z (6 months ago)
- Language: Julia
- Homepage: https://projecttorreypines.github.io/HelpPlots.jl/dev
- Size: 351 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HelpPlots.jl
[](https://github.com/mgyoo86/HelpPlots.jl/actions/workflows/CI.yml?query=branch%3Amain)
## About the Package
`HelpPlots.jl` provides simple utilities to enhance the `@recipe` functionality in `Plots.jl`. It checks the correctness of keyword arguments and displays helpful information so that users can fine-tune their plots. This functionality was originally developed by **Orso Meneghini** and has been extracted into a lightweight, standalone package.
## Note
This package is designed to be independent and lightweight, without strict dependencies on other packages (e.g., it is independent of the `FUSE.jl` ecosystem). However, to use the `help_plot` and `help_plot!` functionalities provided by `HelpPlots.jl`, users must also load the `Plots.jl` package.
## Examples
One can define keyword information inside `@recipe` using `assert_type_and_record_argument` function provided by `HelpPlots.jl` package, like the following example:
```julia
using HelpPlots
# FYI, this recipe is defined in `SimulationParameters.jl` package
@recipe function plot_GroupedParameters(GPs::Vector{GroupedParameter}; nrows=:auto, ncols=:auto, each_size=(500, 400))
id = recipe_dispatch(GPs)
assert_type_and_record_argument(id, Tuple{Integer,Integer}, "Size of each subplot. (Default=(500, 400))"; each_size)
assert_type_and_record_argument(id, Union{Integer,Symbol}, "Number of rows for subplots' layout (Default = :auto)"; nrows)
assert_type_and_record_argument(id, Union{Integer,Symbol}, "Number of columns for subplots' layout (Default = :auto)"; ncols)
# Main body of recipe
...
...
@series begin
...
...
end
end
```
The following examples illustrate how `help_plot` works. See `test/runtests.jl` and `test/my_recipes.jl` for more details.
```julia
# Suppose you have some data and an associated @recipe.
# The following example assumes that you have `inis` and `inis2` as your data,
# and that you are using an @recipe defined in the `SimulationParameters.jl` package.
# This will plot the figure and display the available keyword information.
help_plot(inis)
# This will overlay on the current figure and display the available keyword information.
help_plot!(inis2)
```
The keyword information is printed like the following.
The help_plot function checks the validity of keyword arguments and informs the user if a given keyword is incorrect.
For example:
```julia
# The following call will fail because `each_size` is expected to be a Tuple{Integer, Integer}
help_plot(inis, each_size=123.456)
```
In such a case, `help_plot` produces an error message to guide the user in fixing the keyword.