Creating plotting recipes
The Plots
ecosystem offers the RecipesBase
package so that you can add plotting recipes. It is handy as a package developer since it offers minimum loading overhead for your package. It has no dependencies and enables access to Plots’ plotting capabilities. To that end, the package exports the @recipe
macro, which takes a function definition that describes our recipe. We have different recipe types, depending on the type signature of the defined method, as the system uses Julia’s multiple dispatch.
The @recipe
macro has a special syntax for setting attribute values. We can use the -->
operator to select a different default value for the attribute. This states that the attribute should take the given value if the user has not set it. We can use the :=
operator instead to force a given value for an attribute. Both operators take the attribute on the left-hand side and the desired value on the right-hand side. For example, the following code...