PlotIter
API documentation for PlotIter.
For usage examples, please see the example notebook.
Plotting things from an iterable
PlotIter.plot_iter
— Functionplot_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 typeeltype(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:NoDisplay
: Don'tshow
the plots.DisplayEachRow
: Every time a row of plots is complete,show
it.DisplayAtEnd
: Wait until all plots are generated, and then show all at once.
xlims_convex_hull::Bool=false
: Iff true, callxlims_convex_hull!
on all plots. This requires thedisplay_mode
to beNoDisplay
orDisplayAtEnd
.ylims_convex_hull::Bool=false
: Iff true, callylims_convex_hull!
on all plots. This requires thedisplay_mode
to beNoDisplay
orDisplayAtEnd
.zlims_convex_hull::Bool=false
: Iff true, callzlims_convex_hull!
on all plots. This requires thedisplay_mode
to beNoDisplay
orDisplayAtEnd
.clims_convex_hull::Bool=false
: Iff true, callclims_convex_hull!
on all plots. This requires thedisplay_mode
to beNoDisplay
orDisplayAtEnd
.kwargs...
: Any other keyword arguments specified will be forwarded to an initial call toplot
.
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;
PlotIter.NoDisplay
— Typestruct NoDisplay <: DisplayMode
Don't show any plots.
PlotIter.DisplayEachRow
— Typestruct DisplayEachRow <: DisplayMode
Show a row of plots as soon as it is complete.
PlotIter.DisplayAtEnd
— Typestruct DisplayAtEnd <: DisplayMode
Wait until the iterable is exhausted, and then show all rows of plots.
Axis limits
These functions are used internally by plot_iter
, but they can also be useful standalone.
PlotIter.xlims_convex_hull!
— Functionxlims_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 Subplot
s, then there is no ambiguity over the limits of a given argument. However, if they are Plot
s, 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 i
th subplots.
This is useful to ensure that two plots are visually comparable.
PlotIter.ylims_convex_hull!
— Functionylims_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 Subplot
s, then there is no ambiguity over the limits of a given argument. However, if they are Plot
s, 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 i
th subplots.
This is useful to ensure that two plots are visually comparable.
PlotIter.zlims_convex_hull!
— Functionzlims_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 Subplot
s, then there is no ambiguity over the limits of a given argument. However, if they are Plot
s, 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 i
th subplots.
This is useful to ensure that two plots are visually comparable.
PlotIter.clims_convex_hull!
— Functionclims_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 Subplot
s, then there is no ambiguity over the limits of a given argument. However, if they are Plot
s, 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 i
th subplots.
This is useful to ensure that two plots are visually comparable.