image_ module¶
Utilities for images.
hstack_image_arrays function¶
Stack NumPy images horizontally.
save_animation function¶
save_animation(
fname,
index,
plot_func,
*args,
delta=None,
step=1,
fps=3,
writer_kwargs=None,
show_progress=True,
pbar_kwargs=None,
to_image_kwargs=None,
**kwargs
)
Save animation to a file.
Args
fname:str- File name.
index:sequence- Index to iterate over.
plot_func:callable-
Plotting function.
Must take subset of
index,*args, and**kwargs, and return either a Plotly figure, image that can be read byimageio.imread, or a NumPy array. *args- Positional arguments passed to
plot_func. delta:int- Window size of each iteration.
step:int- Step of each iteration.
fps:int-
Frames per second.
Will be translated to
durationby1000 / fps. writer_kwargs:dict- Keyword arguments passed to
imageio.get_writer. show_progress:bool- Whether to show the progress bar.
pbar_kwargs:dict- Keyword arguments passed to ProgressBar.
to_image_kwargs:dict- Keyword arguments passed to
plotly.graph_objects.Figure.to_image. **kwargs- Keyword arguments passed to
plot_func.
Usage
>>> from vectorbtpro import *
>>> def plot_data_window(index, data):
... return data.loc[index].plot()
>>> data = vbt.YFData.pull("BTC-USD", start="2020", end="2021")
>>> vbt.save_animation(
... "plot_data_window.gif",
... data.index,
... plot_data_window,
... data,
... delta=90,
... step=10
... )
vstack_image_arrays function¶
Stack NumPy images vertically.