flask_plots package¶
Submodules¶
flask_plots.core module¶
Flask-Plots.
Implementation of Matplotlib in Flask.
- class Plots(app=None)[source]¶
Bases:
object
Base extension class for different Plots versions.
New in version 0.0.1.
- static_folder = 'plots'¶
- get_data(fig, fmt='png', decode='ascii')[source]¶
Create a data for embed the result in the html output.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
format (str, default: "png") – A extension type for the images.
decode (str, default: "ascii") – A buffer decode.
- hist(fig, x, ax=None, hist_kws=None)[source]¶
Plot a histogram using Matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x ((n,) array or sequence of (n,) arrays) – Input values, this takes either a single array or a sequence of arrays which are not required to be of the same length.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
hist_kwargs (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- errorbar(fig, x, y, ax=None, errorbar_kws=None)[source]¶
Plot y versus x as lines and/or markers with attached errorbars.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (float or array-like) – The data positions.
y (float or array-like) – The data positions.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
errorbar_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- violinplot(fig, dataset, positions, ax=None, violinplot_kws=None)[source]¶
Make a violin plot using Matlotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
dataset (Array or a sequence of vectors.) – The input data.
positions (array-like, default: [1, 2, ..., n]) – The positions of the violins. The ticks and limits are automatically set to match the positions.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
violinplot_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- eventplot(fig, positions, ax=None, eventplot_kws=None)[source]¶
Plot identical parallel lines at the given positions.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
positions (array-like or list of array-like) – A 1D array-like defines the positions of one sequence of events. Multiple groups of events may be passed as a list of array-likes. Each group can be styled independently by passing lists of values to lineoffsets, linelengths, linewidths, colors and linestyles. Note that positions can be a 2D array, but in practice different event groups usually have different counts so that one will use a list of different-length arrays rather than a 2D array.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
eventplot_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- hist2d(fig, x, y, ax=None, hist2d_kws=None)[source]¶
Make a 2D histogram plot using Matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (array-like, shape (n, )) – Input values
y (array-like, shape (n, )) – Input values
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
hist2d_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- hexbin(fig, x, y, ax=None, hexbin_kws=None)[source]¶
Make a 2D hexagonal binning plot of points x, y using Matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (array-like) – The data positions. x and y must be of the same length.
y (array-like) – The data positions. x and y must be of the same length.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
hexbin_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- scatter_hist2d(fig, x, y, ax=None, hist2d_kws=None, scatter_kws=None)[source]¶
Make a 2D histogram plot using Matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (array-like, shape (n, )) – Input values
y (array-like, shape (n, )) – Input values
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
hist2d_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.scatter_kws (
dict
orNone
(optional)) – The parameters to send to the data plot in term scatter method.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- scatter_hexbin(fig, x, y, ax=None, hexbin_kws=None, scatter_kws=None)[source]¶
Make a 2D scatter-hexagonal binning plot of points x, y.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (array-like) – The data positions. x and y must be of the same length.
y (array-like) – The data positions. x and y must be of the same length.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
hexbin_kws (
dict
orNone
(optional)) – The parameters to send to the data plot in term hexbin method.scatter_kws (
dict
orNone
(optional)) – The parameters to send to the data plot in term scatter method.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- bar(fig, x, bar_height=None, ax=None, bar_kws=None)[source]¶
Make a bar plot using Matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (float or array-like) – The x coordinates of the bars. See also align for the alignment of the bars to the coordinates.
bar_height (float or array-like,) – The height(s) of the bars. You can config this value using
app.config["BAR_HEIGHT"]
.ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
bar_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- pie(fig, x, ax=None, pie_kws=None)[source]¶
Make a pie plot using Matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (1D array-like) – The wedge sizes.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
bar_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- boxplot(fig, x, ax=None, boxplot_kws=None)[source]¶
Draw a box and whisker plot using MAtplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (Array or a sequence of vectors.) – The input data. If a 2D array, a boxplot is drawn for each column in x. If a sequence of 1D arrays, a boxplot is drawn for each array in x.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
boxplot_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- quiver(fig, x, y, u, v, ax=None, quiver_kws=None)[source]¶
Plot a 2D field of arrows using matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (1D or 2D array-like, optional) – The x and y coordinates of the arrow locations. If not given, they will be generated as a uniform integer meshgrid based on the dimensions of u and v. If x and y are 1D but u, v are 2D, x, y are expanded to 2D using
x, y = np.meshgrid(x, y)
. In this caselen(x)
andlen(y)
must match the column and row dimensions of u and v.y (1D or 2D array-like, optional) – The x and y coordinates of the arrow locations. If not given, they will be generated as a uniform integer meshgrid based on the dimensions of u and v. If x and y are 1D but u, v are 2D, x, y are expanded to 2D using
x, y = np.meshgrid(x, y)
. In this caselen(x)
andlen(y)
must match the column and row dimensions of u and v.u (1D or 2D array-like) – The x and y direction components of the arrow vectors. They must have the same number of elements, matching the number of arrow locations. u and v may be masked. Only locations unmasked in u, v, and C will be drawn.
v (1D or 2D array-like) – The x and y direction components of the arrow vectors. They must have the same number of elements, matching the number of arrow locations. u and v may be masked. Only locations unmasked in u, v, and C will be drawn.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
quiver_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis
- streamplot(fig, x, y, u, v, ax=None, streamplot_kws=None)[source]¶
Draw streamlines of a vector flow using matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (1D/2D arrays) – Evenly spaced strictly increasing arrays to make a grid. If 2D, all rows of x must be equal and all columns of y must be equal; i.e., they must be as if generated by
np.meshgrid(x_1d, y_1d)
.y (1D/2D arrays) – Evenly spaced strictly increasing arrays to make a grid. If 2D, all rows of x must be equal and all columns of y must be equal; i.e., they must be as if generated by
np.meshgrid(x_1d, y_1d)
.u (2D arrays) – x and y-velocities. The number of rows and columns must match the length of y and x, respectively.
v (2D arrays) – x and y-velocities. The number of rows and columns must match the length of y and x, respectively.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
streamplot_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- contourf(fig, x, y, z, levels, ax=None, contourf_kws=None)[source]¶
Plot contour lines using matplotlib.
- Parameters
fig (matplotlib.Figure) – A instance of Figure Object.
x (array-like, optional) –
The coordinates of the values in z.
x and y must both be 2D with the same shape as z (e.g. created via numpy.meshgrid), or they must both be 1-D such that
len(x) == N
is the number of columns in z andlen(y) == M
is the number of rows in z.X and Y must both be ordered monotonically.
If not given, they are assumed to be integer indices, i.e.
x = range(N)
,y = range(M)
.y (array-like, optional) –
The coordinates of the values in z.
x and y must both be 2D with the same shape as z (e.g. created via numpy.meshgrid), or they must both be 1-D such that
len(x) == N
is the number of columns in z andlen(y) == M
is the number of rows in z.X and Y must both be ordered monotonically.
If not given, they are assumed to be integer indices, i.e.
x = range(N)
,y = range(M)
.levels (int or array-like, optional) –
Determines the number and positions of the contour lines / regions.
If an int n, use ~matplotlib.ticker.MaxNLocator, which tries to automatically choose no more than n+1 “nice” contour levels between vmin and vmax.
If array-like, draw contour lines at the specified levels. The values must be in increasing order.
ax (matplotlib.Figure.Axis, (optional)) – A matplotlib axis.
contourf_kws (
dict
orNone
(optional)) – The parameters to send to the data plot.
- Returns
ax – A matplotlib axis.
- Return type
matplotlib.Figure.Axis