I also promised a “recipe”. So, Plots is not really a plotting package, in that it does not do any plotting itself. It is a package that allows a user to specify a plot to many different plotting packages in a uniform syntax.
One smart aspect of that is “recipes” that allow a user to define a plot without depending on Plots or any other plotting package . Thus a package can define plots without causing conflicts among plotting packages, and without enforcing any plotting package on the user (though (s)he needs to use Plots to use the recipe).
Here’s how the above plot type could be used to generate a recipe:
using RecipesBase # a tiny package defining the @recipe macro
@userplot SimPlot # defines a plotting function called "simplot"
@recipe function f(h::SimPlot; xlabel1 = "", xlabel2 = "") # define extra keywords to use in the plotting
mat = h.args[1] # the x, y, z data to be plotted are stored in the args array
legend := false # specify the plot attributes
link := :y
grid := false
layout := grid(1, 2, widths = [0.7, 0.3])
@series begin # send the different data to the different subplots
subplot := 2
seriestype := :histogram
orientation := :h
xlabel := xlabel2
title := ""
ylabel := ""
mat[end,:]
end
linealpha --> 0.4 # this (specifying the opacity of the line) can be overridden by the user
seriestype := :path
subplot := 1
xlabel := xlabel1
mat # the recipe returns the data to be plotted
end
You can call this generic plotting function simply
using Plots; gr()
simplot(sims)
But you still have access to the full Plots machinery and can change settings etc to get the same plot as above.