PlotIter

API documentation for PlotIter.

For usage examples, please see the example notebook.

Plotting things from an iterable

PlotIter.plot_iterFunction
plot_iter(f::Function, iterable; kwargs...)

Generate one plot per item of iterable.

This function will call f for each item in iterable, with a new plot set as Plots.current().

It is optimised for use within a Jupyter notebook. It will let you quickly generate a number of plots, making use of the available page width. The plots are then close together, so easier to compare visually.

This function avoids the need to manually construct a layout for this simple case.

Arguments

  • f::Function: A function that takes a single argument of type eltype(iterable). Any return value is ignored.
  • iterable: Any iterable object.

Keyword arguments

  • num_cols::Integer=3: The number of of plots to put side-by-side.
  • row_width=900: The width of each row (that is for all plots in the row)
  • row_height=300: The vertical extent of each plot.
  • display_mode::DisplayMode=DisplayAtEnd(): An instance of:
  • xlims_convex_hull::Bool=false: Iff true, call xlims_convex_hull! on all plots. This requires the display_mode to be NoDisplay or DisplayAtEnd.
  • ylims_convex_hull::Bool=false: Iff true, call ylims_convex_hull! on all plots. This requires the display_mode to be NoDisplay or DisplayAtEnd.
  • zlims_convex_hull::Bool=false: Iff true, call zlims_convex_hull! on all plots. This requires the display_mode to be NoDisplay or DisplayAtEnd.
  • clims_convex_hull::Bool=false: Iff true, call clims_convex_hull! on all plots. This requires the display_mode to be NoDisplay or DisplayAtEnd.
  • kwargs...: Any other keyword arguments specified will be forwarded to an initial call to plot.

Returns

A vector of all plots that have been generated.

Example

Here is the simplest use, with no configuration:

plot_iter(1:3) do i
    # Note: call to `plot!` rather than `plot` is important, since a new plot object has
    # already been created by `plot_iter`.
    plot!(i .* rand(30))
end;

We can also change the sizes, as well as make the y-axis limits match:

plot_iter(1:3; num_cols=2, row_height=500, ylims_convex_hull=true) do i
    plot!(i .* rand(30))
end;
source
PlotIter.DisplayAtEndType
struct DisplayAtEnd <: DisplayMode

Wait until the iterable is exhausted, and then show all rows of plots.

source

Axis limits

These functions are used internally by plot_iter, but they can also be useful standalone.

PlotIter.xlims_convex_hull!Function
xlims_convex_hull!(plots)
xlims_convex_hull!(plots...)

Set the x-axis limits for all plots to the smallest interval that contains all the existing x-axis limits.

If the arguments are Subplots, then there is no ambiguity over the limits of a given argument. However, if they are Plots, then we do the following: * Let n be the minimum number of subplots across all arguments. * For i in 1:n, apply xlimsconvexhull! to the all of the ith subplots.

This is useful to ensure that two plots are visually comparable.

source
PlotIter.ylims_convex_hull!Function
ylims_convex_hull!(plots)
ylims_convex_hull!(plots...)

Set the y-axis limits for all plots to the smallest interval that contains all the existing y-axis limits.

If the arguments are Subplots, then there is no ambiguity over the limits of a given argument. However, if they are Plots, then we do the following: * Let n be the minimum number of subplots across all arguments. * For i in 1:n, apply ylimsconvexhull! to the all of the ith subplots.

This is useful to ensure that two plots are visually comparable.

source
PlotIter.zlims_convex_hull!Function
zlims_convex_hull!(plots)
zlims_convex_hull!(plots...)

Set the z-axis limits for all plots to the smallest interval that contains all the existing z-axis limits.

If the arguments are Subplots, then there is no ambiguity over the limits of a given argument. However, if they are Plots, then we do the following: * Let n be the minimum number of subplots across all arguments. * For i in 1:n, apply zlimsconvexhull! to the all of the ith subplots.

This is useful to ensure that two plots are visually comparable.

source
PlotIter.clims_convex_hull!Function
clims_convex_hull!(plots)
clims_convex_hull!(plots...)

Set the c-axis limits for all plots to the smallest interval that contains all the existing c-axis limits.

If the arguments are Subplots, then there is no ambiguity over the limits of a given argument. However, if they are Plots, then we do the following: * Let n be the minimum number of subplots across all arguments. * For i in 1:n, apply climsconvexhull! to the all of the ith subplots.

This is useful to ensure that two plots are visually comparable.

source