covsirphy.visualization package
Submodules
covsirphy.visualization.bar_plot module
- class BarPlot(filename=None, bbox_inches='tight', **kwargs)[source]
Bases:
VisualizeBase
Create a bar plot.
- Parameters:
- plot(data, vertical=True, colormap=None, color_dict=None, **kwargs)[source]
Create bar plot.
- Parameters:
data (pandas.DataFrame or pandas.Series) –
data to show Index
labels of the bars
- Columns
variables to show
vertical (bool) – whether vertical bar plot (True) or horizontal bar plot (False)
colormap (str, matplotlib colormap object or None) – colormap, please refer to https://matplotlib.org/examples/color/colormaps_reference.html
color_dict (dict[str, str] or None) – dictionary of column names (keys) and colors (values)
kwargs – keyword arguments of pandas.DataFrame.plot()
- bar_plot(df, title=None, filename=None, show_legend=True, **kwargs)[source]
Wrapper function: show chronological change of the data.
- Parameters:
data (pandas.DataFrame or pandas.Series) –
data to show Index
Date (pandas.Timestamp)
- Columns
variables to show
title (str) – title of the figure
filename (str or None) – filename to save the figure or None (display)
show_legend (bool) – whether show legend or not
kwargs – keyword arguments of the following classes and methods. - covsirphy.BarPlot() and its methods, - matplotlib.pyplot.savefig(), matplotlib.pyplot.legend(), - pandas.DataFrame.plot()
covsirphy.visualization.compare_plot module
- class ComparePlot(filename=None, bbox_inches='tight', **kwargs)[source]
Bases:
VisualizeBase
Compare two groups with specified variables.
- Parameters:
- plot(data, variables, groups)[source]
Compare two groups with specified variables.
- Parameters:
data (pandas.DataFrame) –
data to show Index
x values
- Columns
y variables to show, “{variable}_{group}” for all combinations of variables and groups
groups (list[str]) – the first group name and the second group name
- compare_plot(df, variables, groups, filename=None, **kwargs)[source]
Wrapper function: show chronological change of the data.
- Parameters:
df (pandas.DataFrame) –
data to show Index
x values
- Columns
y variables to show, “{variable}_{group}” for all combinations of variables and groups
groups (list[str]) – the first group name and the second group name
filename (str or None) – filename to save the figure or None (display)
kwargs – keyword arguments of the following classes and methods. - matplotlib.pyplot.savefig() - matplotlib.pyplot.legend()
covsirphy.visualization.line_plot module
- class LinePlot(filename=None, bbox_inches='tight', **kwargs)[source]
Bases:
VisualizeBase
Create a line plot.
- Parameters:
- plot(data, colormap=None, color_dict=None, **kwargs)[source]
Plot chronological change of the data.
- Parameters:
data (pandas.DataFrame or pandas.Series) –
data to show Index
x values
- Columns
y variables to show
colormap (str, matplotlib colormap object or None) – colormap, please refer to https://matplotlib.org/examples/color/colormaps_reference.html
color_dict (dict[str, str] or None) – dictionary of column names (keys) and colors (values)
kwargs – keyword arguments of pandas.DataFrame.plot()
- x_axis(xlabel=None, x_logscale=False, xlim=(None, None))[source]
Set x axis.
- Parameters:
Note
If None is included in xlim, the values will be automatically determined by Matplotlib
- line_plot(df, title=None, filename=None, show_legend=True, **kwargs)[source]
Wrapper function: show chronological change of the data.
- Parameters:
data (pandas.DataFrame or pandas.Series) –
data to show Index
Date (pandas.Timestamp)
- Columns
variables to show
title (str) – title of the figure
filename (str or None) – filename to save the figure or None (display)
show_legend (bool) – whether show legend or not
kwargs – keyword arguments of the following classes and methods. - covsirphy.LinePlot() and its methods, - matplotlib.pyplot.savefig(), matplotlib.pyplot.legend(), - pandas.DataFrame.plot()
covsirphy.visualization.scatter_plot module
- class ScatterPlot(filename=None, bbox_inches='tight', **kwargs)[source]
Bases:
LinePlot
Create a scatter plot.
- Parameters:
- line_straight(p1=None, p2=None, color='black', linestyle=':')[source]
Connect the points with a straight line.
- Parameters:
Note
The same line will be show when p1 and p2 is reordered.
- plot(data, colormap=None, color_dict=None, **kwargs)[source]
Plot chronological change of the data.
- Parameters:
data (pandas.DataFrame) –
data to show Index
reset index
- Columns
x (int or float): x values y (int or float): y values
colormap (str, matplotlib colormap object or None) – colormap, please refer to https://matplotlib.org/examples/color/colormaps_reference.html
color_dict (dict[str, str] or None) – dictionary of column names (keys) and colors (values)
kwargs – keyword arguments of pandas.DataFrame.plot()
- scatter_plot(df, title=None, filename=None, **kwargs)[source]
Wrapper function: show chronological change of the data.
- Parameters:
data (pandas.DataFrame) –
data to show Index
reset index
- Columns
x (int or float): x values y (int or float): y values
title (str) – title of the figure
filename (str or None) – filename to save the figure or None (display)
kwargs – keyword arguments of the following classes and methods. - covsirphy.ScatterPlot() and its methods, - matplotlib.pyplot.savefig(), matplotlib.pyplot.legend(), - pandas.DataFrame.plot()
covsirphy.visualization.vbase module
- class VisualizeBase(filename=None, bbox_inches='tight', **kwargs)[source]
Bases:
Term
Base class for visualization.
- Parameters:
- property ax
axis
- Type:
matplotlib.axis
- legend(bbox_to_anchor=(0.5, -0.2), bbox_loc='lower center', ncol=None, **kwargs)[source]
Set legend.
- plot()[source]
Method for plotting. This will be defined in child classes.
- Raises:
NotImplementedError – not implemented