Skip to content

MarketMap

bqplot.market_map.MarketMap

Bases: DOMWidget

Waffle wrapped map. A MarketMap is not a Mark, it's a custom Figure!

ATTRIBUTE DESCRIPTION
names

The elements can also be objects convertible to string primary key for the map data. A rectangle is created for each unique entry in this array

TYPE: numpy.ndarray of strings (default: [])

groups

attribute on which the groupby is run. If this is an empty array, then there is no group by for the map.

TYPE: numpy.ndarray (default: [])

display_text

data to be displayed on each rectangle of the map.If this is empty it defaults to the names attribute.

TYPE: numpy.ndarray or None(default: None)

ref_data

Additional data associated with each element of the map. The data in this data frame can be displayed as a tooltip.

TYPE: pandas.DataDrame or None (default: None)

color

Data to represent the color for each of the cells. If the value of the data is NaN for a cell, then the color of the cell is the color of the group it belongs to in absence of data for color

TYPE: numpy.ndarray (default: [])

scales

If the map has data being passed as color, then a corresponding color scale is required

TYPE: Dictionary of scales holding a scale for each data attribute

axes

Ability to add an axis for the scales which are used to scale data represented in the map

TYPE: List of axes

on_hover

This event is received when the mouse is hovering over a cell. Returns the data of the cell and the ref_data associated with the cell.

TYPE: custom event

tooltip_widget

Widget to be displayed as the tooltip. This can be combined with the on_hover event to display the chart corresponding to the cell being hovered on.

TYPE: Instance of a widget

tooltip_fields

names of the fields from the ref_data dataframe which should be displayed in the tooltip.

TYPE: list

tooltip_formats

formats for each of the fields for the tooltip data. Order should match the order of the tooltip_fields

TYPE: list

freeze_tooltip_location

if True, freezes the location of the tooltip. If False, tooltip will follow the mouse

TYPE: bool (default: False)

show_groups

attribute to determine if the groups should be displayed. If set to True, the finer elements are blurred

TYPE: bool

Map Drawing Attributes
ATTRIBUTE DESCRIPTION
cols

Suggestion for no of columns in the map.If not specified, value is inferred from the no of rows and no of cells

TYPE: int

rows

No of rows in the map.If not specified, value is inferred from the no of cells and no of columns. If both rows and columns are not specified, then a square is constructed basing on the no of cells. The above two attributes are suggestions which are respected unless they are not feasible. One required condition is that, the number of columns is odd when row_groups is greater than 1.

TYPE: int

row_groups

No of groups the rows should be divided into. This can be used to draw more square cells for each of the groups

TYPE: int

Layout Attributes
ATTRIBUTE DESCRIPTION
map_margin

Dictionary containing the top, bottom, left and right margins. The user is responsible for making sure that the width and height are greater than the sum of the margins.

TYPE: dict (default: {top=50, bottom=50, left=50, right=50})

min_aspect_ratio

minimum width / height ratio of the figure

TYPE: float

max_aspect_ratio

maximum width / height ratio of the figure

TYPE: float

Display Attributes
ATTRIBUTE DESCRIPTION
colors

Colors for each of the groups which are cycled over to cover all the groups

TYPE: list of colors

title

Title of the Market Map

TYPE: string

title_style

CSS style for the title of the Market Map

TYPE: dict

stroke

Stroke of each of the cells of the market map

TYPE: color

group_stroke

Stroke of the border for the group of cells corresponding to a group

TYPE: color

selected_stroke

stroke for the selected cells

TYPE: color

hovered_stroke

stroke for the cell being hovered on

TYPE: color

font_style

CSS style for the text of each cell

TYPE: dict

Other Attributes
ATTRIBUTE DESCRIPTION
enable_select

boolean to control the ability to select the cells of the map by clicking

TYPE: bool

enable_hover

boolean to control if the map should be aware of which cell is being hovered on. If it is set to False, tooltip will not be displayed

TYPE: bool

!!! Note

The aspect ratios stand for width / height ratios.

  • If the available space is within bounds in terms of min and max aspect ratio, we use the entire available space.
  • If the available space is too oblong horizontally, we use the client height and the width that corresponds max_aspect_ratio (maximize width under the constraints).
  • If the available space is too oblong vertically, we use the client width and the height that corresponds to min_aspect_ratio (maximize height under the constraint). This corresponds to maximizing the area under the constraints.

Default min and max aspect ratio are both equal to 16 / 9.