Documentation¶
Faerun¶
-
class
faerun.
Faerun
(title: str = '', clear_color: str = '#111111', coords: bool = True, coords_color: str = '#888888', coords_box: bool = False, coords_ticks: bool = True, coords_grid: bool = False, coords_tick_count: int = 10, coords_tick_length: float = 2.0, coords_offset: float = 5.0, x_title: str = '', y_title: str = '', show_legend: bool = True, legend_title: str = 'Legend', legend_orientation: str = 'vertical', legend_number_format: str = '{:.2f}', view: str = 'free', scale: float = 750.0, alpha_blending=False, style: Dict[str, Dict[str, Any]] = {})¶ Creates a faerun object which is an empty plotting surface where layers such as scatter plots can be added.
Constructor for Faerun.
- Keyword Arguments
title (
str
, optional) – The plot titleclear_color (
str
, optional) – The background color of the plotcoords (
bool
, optional) – Show the coordinate axes in the plotcoords_color (
str
, optional) – The color of the coordinate axescoords_box (
bool
, optional) – Show a box around the coordinate axescoords_tick (
bool
, optional) – Show ticks on coordinate axescoords_grid (
bool
, optional) – Extend ticks to create a gridcoords_tick_count (
int
, optional) – The number of ticks to display per axiscoords_tick_length (
float
, optional) – The length of the coordinate tickscoords_offset (
float
, optional) – An offset added to the coordinate axesx_title (
str
, optional) – The title of the x-axisy_title (
str
, optional) – The title of the y-axisshow_legend (
bool
, optional) – Whether or not to show the legendlegend_title (
str
, optional) – The legend titlelegend_orientation (
str
, optional) – The orientation of the legend (‘vertical’ or ‘horizontal’)legend_number_format (
str
, optional) – A format string applied to the numbers displayed in the legendview (
str
, optional) – The view (front, back, top, bottom, left, right, free)scale (
float
, optional) – To what size to scale the coordinates (which are normalized)alpha_blending (
bool
, optional) – Whether to activate alpha blending (required for smoothCircle shader)style (
Dict[str, Dict[str, Any]]
, optional) – The css styles to apply to the HTML elements
-
__init__
(title: str = '', clear_color: str = '#111111', coords: bool = True, coords_color: str = '#888888', coords_box: bool = False, coords_ticks: bool = True, coords_grid: bool = False, coords_tick_count: int = 10, coords_tick_length: float = 2.0, coords_offset: float = 5.0, x_title: str = '', y_title: str = '', show_legend: bool = True, legend_title: str = 'Legend', legend_orientation: str = 'vertical', legend_number_format: str = '{:.2f}', view: str = 'free', scale: float = 750.0, alpha_blending=False, style: Dict[str, Dict[str, Any]] = {})¶ Constructor for Faerun.
- Keyword Arguments
title (
str
, optional) – The plot titleclear_color (
str
, optional) – The background color of the plotcoords (
bool
, optional) – Show the coordinate axes in the plotcoords_color (
str
, optional) – The color of the coordinate axescoords_box (
bool
, optional) – Show a box around the coordinate axescoords_tick (
bool
, optional) – Show ticks on coordinate axescoords_grid (
bool
, optional) – Extend ticks to create a gridcoords_tick_count (
int
, optional) – The number of ticks to display per axiscoords_tick_length (
float
, optional) – The length of the coordinate tickscoords_offset (
float
, optional) – An offset added to the coordinate axesx_title (
str
, optional) – The title of the x-axisy_title (
str
, optional) – The title of the y-axisshow_legend (
bool
, optional) – Whether or not to show the legendlegend_title (
str
, optional) – The legend titlelegend_orientation (
str
, optional) – The orientation of the legend (‘vertical’ or ‘horizontal’)legend_number_format (
str
, optional) – A format string applied to the numbers displayed in the legendview (
str
, optional) – The view (front, back, top, bottom, left, right, free)scale (
float
, optional) – To what size to scale the coordinates (which are normalized)alpha_blending (
bool
, optional) – Whether to activate alpha blending (required for smoothCircle shader)style (
Dict[str, Dict[str, Any]]
, optional) – The css styles to apply to the HTML elements
-
add_scatter
(name: str, data: Union[dict, pandas.core.frame.DataFrame], mapping: dict = {'c': 'c', 'cs': 'cs', 'labels': 'labels', 's': 's', 'x': 'x', 'y': 'y', 'z': 'z'}, colormap: Union[str, matplotlib.colors.Colormap] = 'plasma', shader: str = 'sphere', point_scale: float = 1.0, max_point_size: float = 100.0, fog_intensity: float = 0.0, saturation_limit: float = 0.2, categorical: bool = False, interactive: bool = True, has_legend: bool = False, legend_title: str = None, legend_labels: dict = None, min_legend_label: Union[str, float] = None, max_legend_label: Union[str, float] = None)¶ Add a scatter layer to the plot.
- Parameters
name (
str
) – The name of the layerdata (
dict
orDataFrame
) – A Python dict or Pandas DataFrame containing the data
- Keyword Arguments
mapping (
dict
, optional) – The keys which contain the data in the input dict or the column names in the pandasDataFrame
colormap (
str
orColormap
, optional) – The name of the colormap (can also be a matplotlib Colormap object)shader (
str
, optional) – The name of the shader to use for the data point visualizationpoint_scale (
float
, optional) – The relative size of the data pointsmax_point_size (
int
, optional) – The maximum size of the data points when zooming infog_intensity (
float
, optional) – The intensity of the distance fogsaturation_limit (
float
, optional) – The minimum saturation to avoid “gray soup”categorical (
bool
, optional) – Whether this scatter layer is categoricalinteractive (
bool
, optional) – Whether this scatter layer is interactivehas_legend (
bool
, optional) – Whether or not to draw a legendlegend_title (
str
, optional) – The title of the legendlegend_labels (
dict
, optional) – A dict mapping values to legend labelsmin_legend_label (
Union[str, float]
, option) – The label used for the miminum value in a ranged (non-categorical) legendmax_legend_label (
Union[str, float]
, option) – The label used for the maximum value in a ranged (non-categorical) legend
-
add_tree
(name: str, data: Union[dict, pandas.core.frame.DataFrame], mapping: dict = {'c': 'c', 'from': 'from', 'to': 'to', 'x': 'x', 'y': 'y', 'z': 'z'}, color: str = '#666666', colormap: Union[str, matplotlib.colors.Colormap] = 'plasma', fog_intensity: float = 0.0, point_helper: str = None)¶ Add a tree layer to the plot.
- Parameters
name (
str
) – The name of the layerdata (
dict
orDataFrame
) – A Python dict or Pandas DataFrame containing the data
- Keyword Arguments
mapping (
dict
, optional) – The keys which contain the data in the input dict or DataFramecolor (
str
, optional) – The default color of the treecolormap (
str
orColormap
, optional) – The name of the colormap (can also be a matplotlib Colormap object)fog_intensity (
float
, optional) – The intensity of the distance fogpoint_helper (
str
, optional) – The name of the scatter layer to associate with this tree layer (the source of the coordinates)
-
create_data
() → str¶ Returns a JavaScript string defining a JavaScript object containing the data.
- Returns
JavaScript code defining an object containing the data
- Return type
str
-
create_python_data
() → dict¶ Returns a Python dict containing the data
- Returns
The data defined in this Faerun instance
- Return type
dict
-
static
discrete_cmap
(n_colors: int, base_cmap: str) → matplotlib.colors.Colormap¶ Create an N-bin discrete colormap from the specified input map.
- Parameters
n_colors (
int
) – The number of discrete colors to generate- Keyword Arguments
base_cmap (
str
) – The colormap on which to base the discrete map- Returns
The discrete colormap
- Return type
Colormap
-
get_min_max
() → tuple¶ Get the minimum an maximum coordinates from this plotter instance
- Returns
The minimum and maximum coordinates
- Return type
tuple
-
static
in_notebook
() → bool¶ Checks whether the code is running in an ipython notebook.
- Returns
Whether the code is running in an ipython notebook
- Return type
bool
-
plot
(file_name: str = 'index', path: str = './', template: str = 'default')¶ Plots the data to an HTML / JS file.
- Keyword Arguments
file_name (
str
, optional) – The name of the HTML / JS filepath (
str
, optional) – The path to which to write the HTML / JS filetemplate (
str
, optional) – The name of the template to use
Web¶
-
faerun.
host
(path: str, label_type: str = 'smiles', theme: str = 'light', title: str = 'Faerun', label_formatter: Callable[[str, int, str], str] = None, link_formatter: Callable[[str, int, str], str] = None, info: str = None, legend: bool = False, legend_title: str = 'Legend', view: str = 'front', search_index: int = 1)¶ Start a cherrypy server hosting a Faerun visualization.
- Parameters
path (
str
) – The path to the fearun data file- Keyword Arguments
label_type (
str
) – The type of the labelstheme (
str
) – The theme to use in the front-endtitle (
str
) – The title of the HTML documentlabel_formatter (
Callable[[str, int, str], str]
) – A function used for formatting labelslink_formatter (
Callable[[str, int, str], str]
) – A function used for formatting linksinfo (
str
) – A string containing markdown content that is shown as an info in the visualizationlegend (
bool
) – Whether or not to show the legendlegend_title (
str
) – The title of the legendview (
str
) – The view type (‘front’, ‘back’, ‘top’, ‘bottom’, ‘right’, ‘left’, or ‘free’)search_index (
int
) – The index in the label values that is used for searching