Pyplot
bqplot.pyplot
axes(mark=None, options={}, **kwargs)
Draws axes corresponding to the scales of a given mark.
It also returns a dictionary of drawn axes. If the mark is not provided, the last drawn mark is used.
PARAMETER | DESCRIPTION |
---|---|
mark |
The mark to inspect to create axes. If None, the last mark drawn is used instead.
DEFAULT:
|
options |
Options for the axes to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
DEFAULT:
|
bar(x, y, **kwargs)
Draws a bar chart in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
x |
The x-coordinates of the data points.
|
y |
The y-coordinates of the data pints.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
barh(*args, **kwargs)
Draws a horizontal bar chart in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
x |
The domain of the data points.
|
y |
The range of the data pints.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
bin(sample, options={}, **kwargs)
Draw a histogram in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
sample |
The sample for which the histogram must be generated.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
DEFAULT:
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
boxplot(x, y, **kwargs)
Draws a boxplot in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
x |
The x-coordinates of the data points.
|
y |
The data from which the boxes are to be created. Each row of the data corresponds to one box drawn in the plot.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
brush_int_selector(func=None, trait='selected', **kwargs)
Create a BrushIntervalSelector
interaction for the figure
.
Also attaches the function func
as an event listener for the
specified trait.
PARAMETER | DESCRIPTION |
---|---|
func |
The call back function. It should take at least two arguments. The name of the trait and the value of the trait are passed as arguments.
DEFAULT:
|
trait |
The name of the BrushIntervalSelector trait whose change triggers the
call back function
DEFAULT:
|
brush_selector(func=None, trait='selected', **kwargs)
Creates a BrushSelector
interaction for the figure
.
Also attaches the function func
as an event listener for the
trait trait
.
PARAMETER | DESCRIPTION |
---|---|
func |
The call back function. It should take at least two arguments. The name of the trait and the value of the trait are passed as arguments.
DEFAULT:
|
trait |
The name of the BrushSelector trait whose change triggers the
call back function
DEFAULT:
|
clear()
Clears the current context figure of all marks axes and grid lines.
close(key)
Closes and unregister the context figure corresponding to the key.
PARAMETER | DESCRIPTION |
---|---|
key |
Any variable that can be used as a key for a dictionary
|
current_figure()
Returns the current context figure.
figure(key=None, fig=None, **kwargs)
Creates figures and switches between figures.
If a bqplot.Figure
object is provided via the fig optional argument,
this figure becomes the current context figure.
Otherwise:
- If no key is provided, a new empty context figure is created.
- If a key is provided for which a context already exists, the corresponding context becomes current.
- If a key is provided and no corresponding context exists, a new context is reated for that key and becomes current.
Besides, optional arguments allow to set or modify Attributes of the selected context figure.
PARAMETER | DESCRIPTION |
---|---|
key |
Any variable that can be used as a key for a dictionary
DEFAULT:
|
fig |
A bqplot Figure
DEFAULT:
|
geo(map_data, **kwargs)
Draw a map in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
map_data |
Name of the map or json file required for the map data.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
get_context()
Used for debug only. Return a copy of the current global context dictionary.
gridheatmap(color, **kwargs)
Draw a GridHeatMap in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
color |
Matrix of color of the data points
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
grids(fig=None, value='solid')
Sets the value of the grid_lines for the axis to the passed value.
The default value is solid
.
PARAMETER | DESCRIPTION |
---|---|
fig |
The figure for which the axes should be edited. If the value is None, the current figure is used.
DEFAULT:
|
value |
The display of the grid_lines
DEFAULT:
|
heatmap(color, **kwargs)
Draw a heatmap in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
color |
Matrix of color of the data points
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
hist(sample, options={}, **kwargs)
Draw a histogram in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
sample |
The sample for which the histogram must be generated.
|
options |
Options for the scales to be created. If a scale labeled 'counts' is required for that mark, options['counts'] contains optional keyword arguments for the constructor of the corresponding scale type.
DEFAULT:
|
axes_options |
Options for the axes to be created. If an axis labeled 'counts' is required for that mark, axes_options['counts'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
hline(level, **kwargs)
Draws a horizontal line at the given level.
PARAMETER | DESCRIPTION |
---|---|
level |
The level at which to draw the horizontal line.
|
preserve_domain |
If true, the line does not affect the domain of the 'y' scale.
|
imshow(image, format, **kwargs)
Draw an image in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
image |
Image data, depending on the passed format, can be one of: - an instance of an ipywidgets Image - a file name - a raw byte string
|
format |
Type of the input argument. If not 'widget' or 'filename', must be a format supported by the ipywidgets Image.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
index_selector(func=None, trait='selected', **kwargs)
Creates an IndexSelector
interaction for the figure
.
Also attaches the function func
as an event listener for the
trait trait
.
PARAMETER | DESCRIPTION |
---|---|
func |
The call back function. It should take at least two arguments. The name of the trait and the value of the trait are passed as arguments.
DEFAULT:
|
trait |
The name of the IndexSelector trait whose change triggers the
call back function
DEFAULT:
|
int_selector(func=None, trait='selected', **kwargs)
Creates a FastIntervalSelector
interaction for the figure
.
Also attaches the function func
as an event listener for the
trait trait
.
PARAMETER | DESCRIPTION |
---|---|
func |
The call back function. It should take at least two arguments. The name of the trait and the value of the trait are passed as arguments.
DEFAULT:
|
trait |
The name of the IntervalSelector trait whose change triggers the
call back function
DEFAULT:
|
label(text, **kwargs)
Draws a Label in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
text |
The label to be displayed.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
lasso_selector(func=None, trait='selected', **kwargs)
Creates a LassoSelector
interaction for the figure
.
Also attaches the function func
as an event listener for the
specified trait.
PARAMETER | DESCRIPTION |
---|---|
func |
The call back function. It should take at least two arguments. The name of the trait and the value of the trait are passed as arguments.
DEFAULT:
|
trait |
The name of the LassoSelector trait whose change triggers the
call back function
DEFAULT:
|
legend()
Places legend in the current figure.
multi_selector(func=None, trait='selected', **kwargs)
Creates a MultiSelector
interaction for the figure
.
Also attaches the function func
as an event listener for the
trait trait
.
PARAMETER | DESCRIPTION |
---|---|
func |
The call back function. It should take at least two arguments. The name of the trait and the value of the trait are passed as arguments.
DEFAULT:
|
trait |
The name of the MultiSelector trait whose change triggers the
call back function
DEFAULT:
|
ohlc(*args, **kwargs)
Draw OHLC bars or candle bars in the current context figure.
Signature: ohlc(x, y, **kwargs)
or ohlc(y, **kwargs)
, depending of the
length of the list of positional arguments. In the case where the x
array
is not provided
PARAMETER | DESCRIPTION |
---|---|
x |
The x-coordinates of the plotted line. When not provided, the function
defaults to
|
y |
The ohlc (open/high/low/close) information. A two dimensional array. y must have the shape (n, 4).
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
pie(sizes, **kwargs)
Draws a Pie in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
sizes |
The proportions to be represented by the Pie.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
plot(*args, **kwargs)
Draw lines in the current context figure.
Signature: plot(x, y, **kwargs)
or plot(y, **kwargs)
, depending of the
length of the list of positional arguments. In the case where the x
array
is not provided.
PARAMETER | DESCRIPTION |
---|---|
x |
The x-coordinates of the plotted line. When not provided, the function
defaults to
|
y |
The y-coordinates of the plotted line. If argument
|
marker_str |
string representing line_style, marker and color. For e.g. 'g--o', 'sr' etc
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
figure |
The figure to which the line is to be added. If the value is None, the current figure is used.
|
scales(key=None, scales={})
Creates and switches between context scales.
If no key is provided, a new blank context is created.
If a key is provided for which a context already exists, the existing context is set as the current context.
If a key is provided and no corresponding context exists, a new context is created for that key and set as the current context.
PARAMETER | DESCRIPTION |
---|---|
key |
Any variable that can be used as a key for a dictionary
DEFAULT:
|
scales |
Dictionary of scales to be used in the new context
DEFAULT:
|
Example
>>> scales(scales={
>>> 'x': Keep,
>>> 'color': ColorScale(min=0, max=1)
>>> })
This creates a new scales context, where the 'x' scale is kept from the previous context, the 'color' scale is an instance of ColorScale provided by the user. Other scales, potentially needed such as the 'y' scale in the case of a line chart will be created on the fly when needed.
Notes
Every call to the function figure triggers a call to scales.
The scales
parameter is ignored if the key
argument is not Keep and
context scales already exist for that key.
scatter(x, y, **kwargs)
Draw a scatter in the current context figure.
PARAMETER | DESCRIPTION |
---|---|
x |
The x-coordinates of the data points.
|
y |
The y-coordinates of the data points.
|
options |
Options for the scales to be created. If a scale labeled 'x' is required for that mark, options['x'] contains optional keyword arguments for the constructor of the corresponding scale type.
|
axes_options |
Options for the axes to be created. If an axis labeled 'x' is required for that mark, axes_options['x'] contains optional keyword arguments for the constructor of the corresponding axis type.
|
set_cmap(cmap)
Set the color map of the current 'color' scale.
set_context(context)
Sets the current global context dictionary. All the attributes to be set should be set. Otherwise, it will result in unpredictable behavior.
set_lim(min, max, name)
Set the domain bounds of the scale associated with the provided key.
PARAMETER | DESCRIPTION |
---|---|
name |
Any variable that can be used as a key for a dictionary
|
RAISES | DESCRIPTION |
---|---|
KeyError
|
When no context figure is associated with the provided key. |
show(key=None, display_toolbar=True)
Shows the current context figure in the output area.
PARAMETER | DESCRIPTION |
---|---|
key |
Any variable that can be used as a key for a dictionary.
TYPE:
|
display_toolbar |
If True, a toolbar for different mouse interaction is displayed with the figure.
DEFAULT:
|
RAISES | DESCRIPTION |
---|---|
KeyError
|
When no context figure is associated with the provided key. |
Examples:
>>> import numpy as np
>>> import pyplot as plt
>>> n = 100
>>> x = np.arange(n)
>>> y = np.cumsum(np.random.randn(n))
>>> plt.plot(x,y)
>>> plt.show()
title(label, style=None)
Sets the title for the current figure.
PARAMETER | DESCRIPTION |
---|---|
label |
The new title for the current figure.
TYPE:
|
style |
The CSS style to be applied to the figure title
DEFAULT:
|
vline(level, **kwargs)
Draws a vertical line at the given level.
PARAMETER | DESCRIPTION |
---|---|
level |
The level at which to draw the vertical line.
|
preserve_domain |
If true, the line does not affect the domain of the 'x' scale.
|
xlabel(label=None, mark=None, **kwargs)
Sets the value of label for an axis whose associated scale has the
dimension x
.
PARAMETER | DESCRIPTION |
---|---|
label |
The label for x axis
DEFAULT:
|
xlim(min, max)
Set the domain bounds of the current 'x' scale.
ylabel(label=None, mark=None, **kwargs)
Sets the value of label for an axis whose associated scale has the
dimension y
.
PARAMETER | DESCRIPTION |
---|---|
label |
The label for y axis
DEFAULT:
|
ylim(min, max)
Set the domain bounds of the current 'y' scale.