Module datapane.client.api.files

Creating charts.

We recommend using Altair/pdvega for generating interactive charts: use the supplied save() function.

Example

altair_pandas:: # uses the default pandas plotting API from datapane.files import save

import numpy as np

pd.set_option('plotting.backend', 'altair') # Installing altair_pandas registers this.

data = pd.DataFrame({'x': np.random.randn(200), 'y': np.random.randn(200)})

plot = data.plot.scatter('x', 'y') save(plot, "scatter")

pdvega::

from datapane.files import save

import numpy as np import pdvega

data = pd.DataFrame({'x': np.random.randn(200), 'y': np.random.randn(200)})

plot = data.vgplot.scatter('x', 'y') save(plot, "scatter")

altair::

from datapane.files import save

import altair as alt import numpy as np

data = pd.DataFrame({'x': np.random.randn(20), 'y': np.random.randn(20)}) plot = alt.Chart(data).mark_bar().encode( y='y', x='x' )

save(plot, "bars")

Also for your convenience the save() function is compatible with matplotlib figures, Bokeh Figures, and pandas dataframes (it saves a table in this instance).

Example

::

from datapane.files import save

import matplotlib.pyplot as plt

fig, ax = plt.subplots() ax.plot([1, 2, 3, 4], [1, 4, 9, 16]) save(figure, "line.svg") out_df = in_df

Functions

def get_wrapper(x: Any, default_to_json: bool, error_msg: Union[str, NoneType] = None) ‑> BaseAsset
def save(obj: Any, default_to_json: bool = False) ‑> datapane.client.api.common.DPTmpFile
def convert(obj: Any) ‑> DataBlock

Attempt to convert/wrap a 'primitive' Python object into a Datapane 'boxed' object

Classes

class BaseAsset (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

  • typing.Generic
  • abc.ABC

Subclasses

Class variables

var mimetype : str
var obj_type : ~T
var block_type : Type[DataBlock]
var ext : str
var file_mode : str

Methods

def write(self, x: ~T) ‑> datapane.client.api.common.DPTmpFile
def write_file(self, f: , x: ~T)
def to_block(self, x: ~T) ‑> DataBlock
class BasePickleWriter (*args, **kwds)

Creates a pickle file from any object

Ancestors

Class variables

var mimetype : str
var obj_type : ~T
var block_type : Type[DataBlock]

File blocks are used to attach a file to the report that can be displayed (if possible) and downloaded by report viewers

Any types of files may be attached, for instance, images (png / jpg), PDFs, JSON data, Excel files, etc.

var ext : str
var file_mode : str

Methods

def write_file(self, f: , x: Any)
class BaseJsonWriter (*args, **kwds)

Creates a JSON file from any object

Ancestors

Class variables

var file_mode : str
var mimetype : str
var obj_type : ~T
var block_type : Type[DataBlock]

File blocks are used to attach a file to the report that can be displayed (if possible) and downloaded by report viewers

Any types of files may be attached, for instance, images (png / jpg), PDFs, JSON data, Excel files, etc.

var ext : str

Methods

def write_file(self, f: , x: Any)
class StringWrapper (*args, **kwds)

Creates a Json for a string File, or Markdown for a Block

Ancestors

Class variables

var file_mode : str
var mimetype : str
var obj_type : ~T

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

var block_type : Type[DataBlock]

Markdown objects store Markdown text that can be displayed as formatted text when viewing your report.

Note: This object is also available as dp.Text, and any strings provided directly to the Report/Group object are converted automatically to Markdown blocks

Tip: You can also insert a dataframe in a Markdown block as a table by using df.to_markdown(), or use dp.Table or dp.DataTable for dedicated dataframe tables.

var ext : str

Methods

def write_file(self, f: , x: Any)
class PathWrapper (*args, **kwds)

Creates a File block around Path objects

Ancestors

Class variables

var mimetype : str
var ext : str
var file_mode : str
var obj_type : ~T

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

var block_type : Type[DataBlock]

File blocks are used to attach a file to the report that can be displayed (if possible) and downloaded by report viewers

Any types of files may be attached, for instance, images (png / jpg), PDFs, JSON data, Excel files, etc.

Methods

def to_block(self, x: ~T) ‑> DataBlock
class BaseTable (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Subclasses

Class variables

var obj_type : ~U
var mimetype : str
var ext : str
var TABLE_CELLS_LIMIT : int
var block_type : Type[DataBlock]

Table blocks store the contents of a dataframe as a HTML table whose style can be customised using pandas' Styler API.

var allowed_attrs
var allowed_tags
var allowed_protocols

Methods

def write_file(self, f: , x: ~U)
def to_block(self, x: ~T) ‑> DataBlock
def render_html(self, obj: ~U) ‑> str
class StylerTable (*args, **kwds)

Creates a styled html table from a pandas Styler object

Ancestors

Class variables

var TABLE_CELLS_LIMIT : int
var obj_type : ~U

Helps style a DataFrame or Series according to the data with HTML and CSS.

Parameters

data : Series or DataFrame
Data to be styled - either a Series or DataFrame.
precision : int
Precision to round floats to, defaults to pd.options.display.precision.
table_styles : list-like, default None
List of {selector: (attr, value)} dicts; see Notes.
uuid : str, default None
A unique identifier to avoid CSS collisions; generated automatically.
caption : str, default None
Caption to attach to the table.
table_attributes : str, default None
Items that show up in the opening <table> tag in addition to automatic (by default) id.
cell_ids : bool, default True
If True, each cell will have an id attribute in their HTML tag. The id takes the form T_<uuid>_row<num_row>_col<num_col> where <uuid> is the unique identifier, <num_row> is the row number and <num_col> is the column number.
na_rep : str, optional

Representation for missing values. If na_rep is None, no special formatting is applied.

Added in version: 1.0.0

Attributes

env : Jinja2 jinja2.Environment
 
template : Jinja2 Template
 
loader : Jinja2 Loader
 

See Also

DataFrame.style
Return a Styler object containing methods for building a styled HTML representation for the DataFrame.

Notes

Most styling will be done by passing style functions into Styler.apply or Styler.applymap. Style functions should return values with strings containing CSS 'attr: value' that will be applied to the indicated cells.

If using in the Jupyter notebook, Styler has defined a _repr_html_ to automatically render itself. Otherwise call Styler.render to get the generated HTML.

CSS classes are attached to the generated HTML

  • Index and Column names include index_name and level<k> where k is its level in a MultiIndex
  • Index label cells include

  • row_heading

  • row<n> where n is the numeric position of the row
  • level<k> where k is the level in a MultiIndex

  • Column label cells include

  • col_heading
  • col<n> where n is the numeric position of the column
  • level<k> where k is the level in a MultiIndex

  • Blank cells include blank

  • Data cells include data
var block_type : Type[DataBlock]

Inherited from: BaseTable.block_type

Table blocks store the contents of a dataframe as a HTML table whose style can be customised using pandas' Styler API.

Methods

def render_html(self, obj: ~U) ‑> str
class DataFrameTable (*args, **kwds)

Creates an html table from the dataframe

Ancestors

Class variables

var TABLE_CELLS_LIMIT : int
var obj_type : ~U

Two-dimensional, size-mutable, potentially heterogeneous tabular data.

Data structure also contains labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects. The primary pandas data structure.

Parameters

data : ndarray (structured or homogeneous), Iterable, dict, or DataFrame

Dict can contain Series, arrays, constants, or list-like objects.

Changed in version: 0.23.0

If data is a dict, column order follows insertion-order for Python 3.6 and later.

Changed in version: 0.25.0

If data is a list of dicts, column order follows insertion-order for Python 3.6 and later.

index : Index or array-like
Index to use for resulting frame. Will default to RangeIndex if no indexing information part of input data and no index provided.
columns : Index or array-like
Column labels to use for resulting frame. Will default to RangeIndex (0, 1, 2, …, n) if no column labels are provided.
dtype : dtype, default None
Data type to force. Only a single dtype is allowed. If None, infer.
copy : bool, default False
Copy data from inputs. Only affects DataFrame / 2d ndarray input.

See Also

DataFrame.from_records
Constructor from tuples, also record arrays.
DataFrame.from_dict
From dicts of Series, arrays, or dicts.
read_csv
Read a comma-separated values (csv) file into DataFrame.
read_table
Read general delimited file into DataFrame.
read_clipboard
Read text from clipboard into DataFrame.

Examples

Constructing DataFrame from a dictionary.

>>> d = {'col1': [1, 2], 'col2': [3, 4]}
>>> df = pd.DataFrame(data=d)
>>> df
   col1  col2
0     1     3
1     2     4

Notice that the inferred dtype is int64.

>>> df.dtypes
col1    int64
col2    int64
dtype: object

To enforce a single dtype:

>>> df = pd.DataFrame(data=d, dtype=np.int8)
>>> df.dtypes
col1    int8
col2    int8
dtype: object

Constructing DataFrame from numpy ndarray:

>>> df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
...                    columns=['a', 'b', 'c'])
>>> df2
   a  b  c
0  1  2  3
1  4  5  6
2  7  8  9
var block_type : Type[DataBlock]

Inherited from: BaseTable.block_type

Table blocks store the contents of a dataframe as a HTML table whose style can be customised using pandas' Styler API.

Methods

def render_html(self, obj: ~U) ‑> str
class PlotAsset (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Subclasses

Class variables

var mimetype : str
var obj_type : ~T
var ext : str
var file_mode : str
var block_type : Type[DataBlock]

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your report when viewed in the browser.

class MatplotBasePlot (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Subclasses

Class variables

var obj_type : ~T
var block_type : Type[DataBlock]

Inherited from: PlotAsset.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var file_mode : str
var ext : str
var mimetype : str
class MatplotFigurePlot (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Class variables

var mimetype : str
var block_type : Type[DataBlock]

Inherited from: MatplotBasePlot.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var ext : str
var file_mode : str
var obj_type : ~T

The top level container for all the plot elements.

The Figure instance supports callbacks through a callbacks attribute which is a .CallbackRegistry instance. The events you can connect to are 'dpi_changed', and the callback will be called with func(fig) where fig is the Figure instance.

Attributes

patch
The .Rectangle instance representing the figure background patch.
suppressComposite
For multiple figure images, the figure will make composite images depending on the renderer option_image_nocomposite function. If suppressComposite is a boolean, this will override the renderer.

Methods

def write(self, x: matplotlib.figure.Figure) ‑> datapane.client.api.common.DPTmpFile
class MatplotAxesPlot (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Class variables

var mimetype : str
var block_type : Type[DataBlock]

Inherited from: MatplotBasePlot.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var ext : str
var file_mode : str
var obj_type : ~T

The Axes contains most of the figure elements: ~.axis.Axis, ~.axis.Tick, ~.lines.Line2D, ~.text.Text, ~.patches.Polygon, etc., and sets the coordinate system.

The Axes instance supports callbacks through a callbacks attribute which is a ~.cbook.CallbackRegistry instance. The events you can connect to are 'xlim_changed' and 'ylim_changed' and the callback will be called with func(ax) where ax is the Axes instance.

Attributes

dataLim : .Bbox
The bounding box enclosing all data displayed in the Axes.
viewLim : .Bbox
The view limits in data coordinates.

Methods

def write(self, x: matplotlib.axes._axes.Axes) ‑> datapane.client.api.common.DPTmpFile
class MatplotNDArrayPlot (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Class variables

var mimetype : str
var block_type : Type[DataBlock]

Inherited from: MatplotBasePlot.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var ext : str
var file_mode : str
var obj_type : ~T

ndarray(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)

An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)

Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.

For more information, refer to the numpy module and examine the methods and attributes of an array.

Parameters

(for the new method; see Notes below)

shape : tuple of ints
Shape of created array.
dtype : data-type, optional
Any object that can be interpreted as a numpy data type.
buffer : object exposing buffer interface, optional
Used to fill the array with data.
offset : int, optional
Offset of array data in buffer.
strides : tuple of ints, optional
Strides of data in memory.
order : {'C', 'F'}, optional
Row-major (C-style) or column-major (Fortran-style) order.

Attributes

T : ndarray
Transpose of the array.
data : buffer
The array's elements, in memory.
dtype : dtype object
Describes the format of the elements in the array.
flags : dict
Dictionary containing information related to memory use, e.g., 'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.
flat : numpy.flatiter object
Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).
imag : ndarray
Imaginary part of the array.
real : ndarray
Real part of the array.
size : int
Number of elements in the array.
itemsize : int
The memory use of each array element in bytes.
nbytes : int
The total number of bytes required to store the array data, i.e., itemsize * size.
ndim : int
The array's number of dimensions.
shape : tuple of ints
Shape of the array.
strides : tuple of ints
The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).
ctypes : ctypes object
Class containing properties of the array needed for interaction with ctypes.
base : ndarray
If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.

See Also

array
Construct an array.
zeros
Create an array, each element of which is zero.
empty
Create an array, but leave its allocated memory unchanged (i.e., it contains "garbage").
dtype
Create a data-type.

Notes

There are two modes of creating an array using __new__:

  1. If buffer is None, then only shape, dtype, and order are used.
  2. If buffer is an object exposing the buffer interface, then all keywords are interpreted.

No __init__ method is needed because the array is fully initialized after the __new__ method.

Examples

These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.

First mode, buffer is None:

>>> np.ndarray(shape=(2,2), dtype=float, order='F')
array([[0.0e+000, 0.0e+000], # random
       [     nan, 2.5e-323]])

Second mode:

>>> np.ndarray((2,), buffer=np.array([1,2,3]),
...            offset=np.int_().itemsize,
...            dtype=int) # offset = 1*itemsize, i.e. skip first element
array([2, 3])

Methods

def write(self, x: numpy.ndarray) ‑> datapane.client.api.common.DPTmpFile
class BokehBasePlot (*args, **kwds)

Returns an interactive Bokeh application, supports both basic plots and layout plots via subclasses

Ancestors

Subclasses

Class variables

var obj_type : ~T
var block_type : Type[DataBlock]

Inherited from: PlotAsset.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var file_mode : str
var mimetype : str
var ext : str

Methods

def write_file(self, f: , app)
class BokehPlot (*args, **kwds)

Returns an interactive Bokeh application, supports both basic plots and layout plots via subclasses

Ancestors

Class variables

var mimetype : str
var block_type : Type[DataBlock]

Inherited from: BokehBasePlot.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var ext : str
var file_mode : str
var obj_type : ~T

Create a new Figure for plotting.

A subclass of :class:~bokeh.models.plots.Plot that simplifies plot creation with default axes, grids, tools, etc.

Figure objects have many glyph methods that can be used to draw vectorized graphical glyphs:

Hlist

:columns: 3

  • :func:~bokeh.plotting.figure.Figure.annular_wedge
  • :func:~bokeh.plotting.figure.Figure.annulus
  • :func:~bokeh.plotting.figure.Figure.arc
  • :func:~bokeh.plotting.figure.Figure.asterisk
  • :func:~bokeh.plotting.figure.Figure.bezier
  • :func:~bokeh.plotting.figure.Figure.circle
  • :func:~bokeh.plotting.figure.Figure.circle_cross
  • :func:~bokeh.plotting.figure.Figure.circle_dot
  • :func:~bokeh.plotting.figure.Figure.circle_x
  • :func:~bokeh.plotting.figure.Figure.circle_y
  • :func:~bokeh.plotting.figure.Figure.cross
  • :func:~bokeh.plotting.figure.Figure.dash
  • :func:~bokeh.plotting.figure.Figure.diamond
  • :func:~bokeh.plotting.figure.Figure.diamond_cross
  • :func:~bokeh.plotting.figure.Figure.diamond_dot
  • :func:~bokeh.plotting.figure.Figure.dot
  • :func:~bokeh.plotting.figure.Figure.ellipse
  • :func:~bokeh.plotting.figure.Figure.harea
  • :func:~bokeh.plotting.figure.Figure.hbar
  • :func:~bokeh.plotting.figure.Figure.hex
  • :func:~bokeh.plotting.figure.Figure.hex_tile
  • :func:~bokeh.plotting.figure.Figure.image
  • :func:~bokeh.plotting.figure.Figure.image_rgba
  • :func:~bokeh.plotting.figure.Figure.image_url
  • :func:~bokeh.plotting.figure.Figure.inverted_triangle
  • :func:~bokeh.plotting.figure.Figure.line
  • :func:~bokeh.plotting.figure.Figure.multi_line
  • :func:~bokeh.plotting.figure.Figure.multi_polygons
  • :func:~bokeh.plotting.figure.Figure.oval
  • :func:~bokeh.plotting.figure.Figure.patch
  • :func:~bokeh.plotting.figure.Figure.patches
  • :func:~bokeh.plotting.figure.Figure.plus
  • :func:~bokeh.plotting.figure.Figure.quad
  • :func:~bokeh.plotting.figure.Figure.quadratic
  • :func:~bokeh.plotting.figure.Figure.ray
  • :func:~bokeh.plotting.figure.Figure.rect
  • :func:~bokeh.plotting.figure.Figure.segment
  • :func:~bokeh.plotting.figure.Figure.square
  • :func:~bokeh.plotting.figure.Figure.square_cross
  • :func:~bokeh.plotting.figure.Figure.square_dot
  • :func:~bokeh.plotting.figure.Figure.square_pin
  • :func:~bokeh.plotting.figure.Figure.square_x
  • :func:~bokeh.plotting.figure.Figure.step
  • :func:~bokeh.plotting.figure.Figure.text
  • :func:~bokeh.plotting.figure.Figure.triangle
  • :func:~bokeh.plotting.figure.Figure.triangle_dot
  • :func:~bokeh.plotting.figure.Figure.triangle_pin
  • :func:~bokeh.plotting.figure.Figure.varea
  • :func:~bokeh.plotting.figure.Figure.vbar
  • :func:~bokeh.plotting.figure.Figure.wedge
  • :func:~bokeh.plotting.figure.Figure.x
  • :func:~bokeh.plotting.figure.Figure.y

There is a scatter function that can be parameterized by marker type:

  • :func:~bokeh.plotting.figure.Figure.scatter

There are also specialized methods for stacking bars:

  • bars: :func:~bokeh.plotting.figure.Figure.hbar_stack, :func:~bokeh.plotting.figure.Figure.vbar_stack
  • lines: :func:~bokeh.plotting.figure.Figure.hline_stack, :func:~bokeh.plotting.figure.Figure.vline_stack
  • areas: :func:~bokeh.plotting.figure.Figure.harea_stack, :func:~bokeh.plotting.figure.Figure.varea_stack

As well as one specialized method for making simple hexbin plots:

  • :func:~bokeh.plotting.figure.Figure.hexbin

In addition to all the Figure property attributes, the following options are also accepted:

.. bokeh-options:: FigureOptions :module: bokeh.plotting.figure

class BokehLayoutPlot (*args, **kwds)

Returns an interactive Bokeh application, supports both basic plots and layout plots via subclasses

Ancestors

Class variables

var mimetype : str
var block_type : Type[DataBlock]

Inherited from: BokehBasePlot.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var ext : str
var file_mode : str
var obj_type : ~T

The base class for layoutable components.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

class AltairPlot (*args, **kwds)

Creates a vega-light chart from Altair Chart / pdvega Axes object.

Ancestors

Class variables

var block_type : Type[DataBlock]

Inherited from: PlotAsset.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var file_mode : str
var mimetype : str
var ext : str
var obj_type : ~T

Base class for schema wrappers.

Each derived class should set the _schema class attribute (and optionally the _rootschema class attribute) which is used for validation.

Methods

def write_file(self, f: , chart: altair.utils.schemapi.SchemaBase)
class PlotlyPlot (*args, **kwds)

Creates a plotly graph from a figure object

Ancestors

Class variables

var block_type : Type[DataBlock]

Inherited from: PlotAsset.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var file_mode : str
var mimetype : str
var ext : str
var obj_type : ~T

Base class for all figure types (both widget and non-widget)

Methods

def write_file(self, f: , chart: plotly.graph_objs._figure.Figure)
class FoliumPlot (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Class variables

var block_type : Type[DataBlock]

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your report when viewed in the browser.

var file_mode : str
var mimetype : str
var ext : str
var obj_type : ~T

Create a Map with Folium and Leaflet.js

Generate a base map of given width and height with either default tilesets or a custom tileset URL. The following tilesets are built-in to Folium. Pass any of the following to the "tiles" keyword:

- "OpenStreetMap"
- "Mapbox Bright" (Limited levels of zoom for free tiles)
- "Mapbox Control Room" (Limited levels of zoom for free tiles)
- "Stamen" (Terrain, Toner, and Watercolor)
- "Cloudmade" (Must pass API key)
- "Mapbox" (Must pass API key)
- "CartoDB" (positron and dark_matter)

You can pass a custom tileset to Folium by passing a Leaflet-style URL to the tiles parameter: http://{s}.yourtiles.com/{z}/{x}/{y}.png.

You can find a list of free tile providers here: http://leaflet-extras.github.io/leaflet-providers/preview/. Be sure to check their terms and conditions and to provide attribution with the attr keyword.

Parameters

location : tuple or list, default None
Latitude and Longitude of Map (Northing, Easting).
width : pixel int or percentage string (default: '100%')
Width of the map.
height : pixel int or percentage string (default: '100%')
Height of the map.
tiles : str, default 'OpenStreetMap'
Map tileset to use. Can choose from a list of built-in tiles, pass a custom URL or pass None to create a map without tiles. For more advanced tile layer options, use the TileLayer class.
min_zoom : int, default 0
Minimum allowed zoom level for the tile layer that is created.
max_zoom : int, default 18
Maximum allowed zoom level for the tile layer that is created.
zoom_start : int, default 10
Initial zoom level for the map.
attr : string, default None
Map tile attribution; only required if passing custom tile URL.
crs : str, default 'EPSG3857'
Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back. You can use Leaflet's values : * EPSG3857 : The most common CRS for online maps, used by almost all free and commercial tile providers. Uses Spherical Mercator projection. Set in by default in Map's crs option. * EPSG4326 : A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. * EPSG3395 : Rarely used by some commercial tile providers. Uses Elliptical Mercator projection. * Simple : A simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps). Note that the y axis should still be inverted (going from bottom to top).
control_scale : bool, default False
Whether to add a control scale on the map.
prefer_canvas : bool, default False
Forces Leaflet to use the Canvas back-end (if available) for vector layers instead of SVG. This can increase performance considerably in some cases (e.g. many thousands of circle markers on the map).
no_touch : bool, default False
Forces Leaflet to not use touch events even if it detects them.
disable_3d : bool, default False
Forces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning (which may cause glitches in some rare environments) even if they're supported.
zoom_control : bool, default True
Display zoom controls on the map.
**kwargs
Additional keyword arguments are passed to Leaflets Map class: https://leafletjs.com/reference-1.6.0.html#map

Returns

Folium Map Object
 

Examples

>>> m = folium.Map(location=[45.523, -122.675], width=750, height=500)
>>> m = folium.Map(location=[45.523, -122.675], tiles='cartodb positron')
>>> m = folium.Map(
...    location=[45.523, -122.675],
...    zoom_start=2,
...    tiles='https://api.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=mytoken',
...    attr='Mapbox attribution'
...)

Methods

def write_file(self, f: , m: folium.folium.Map)
class p (*args, **kwds)

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as::

class Mapping(Generic[KT, VT]): def getitem(self, key: KT) -> VT: … # Etc.

This class can then be used as follows::

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

Ancestors

Class variables

var block_type : Type[DataBlock]

Inherited from: PlotAsset.block_type

Plot blocks store a Python-based plot object, including ones created by Altair, Plotly, Matplotlib, Bokeh, and Folium, for interactive display in your …

var file_mode : str
var mimetype : str
var ext : str
var obj_type : ~T

Create a Map with Folium and Leaflet.js

Generate a base map of given width and height with either default tilesets or a custom tileset URL. The following tilesets are built-in to Folium. Pass any of the following to the "tiles" keyword:

- "OpenStreetMap"
- "Mapbox Bright" (Limited levels of zoom for free tiles)
- "Mapbox Control Room" (Limited levels of zoom for free tiles)
- "Stamen" (Terrain, Toner, and Watercolor)
- "Cloudmade" (Must pass API key)
- "Mapbox" (Must pass API key)
- "CartoDB" (positron and dark_matter)

You can pass a custom tileset to Folium by passing a Leaflet-style URL to the tiles parameter: http://{s}.yourtiles.com/{z}/{x}/{y}.png.

You can find a list of free tile providers here: http://leaflet-extras.github.io/leaflet-providers/preview/. Be sure to check their terms and conditions and to provide attribution with the attr keyword.

Parameters

location : tuple or list, default None
Latitude and Longitude of Map (Northing, Easting).
width : pixel int or percentage string (default: '100%')
Width of the map.
height : pixel int or percentage string (default: '100%')
Height of the map.
tiles : str, default 'OpenStreetMap'
Map tileset to use. Can choose from a list of built-in tiles, pass a custom URL or pass None to create a map without tiles. For more advanced tile layer options, use the TileLayer class.
min_zoom : int, default 0
Minimum allowed zoom level for the tile layer that is created.
max_zoom : int, default 18
Maximum allowed zoom level for the tile layer that is created.
zoom_start : int, default 10
Initial zoom level for the map.
attr : string, default None
Map tile attribution; only required if passing custom tile URL.
crs : str, default 'EPSG3857'
Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back. You can use Leaflet's values : * EPSG3857 : The most common CRS for online maps, used by almost all free and commercial tile providers. Uses Spherical Mercator projection. Set in by default in Map's crs option. * EPSG4326 : A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. * EPSG3395 : Rarely used by some commercial tile providers. Uses Elliptical Mercator projection. * Simple : A simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps). Note that the y axis should still be inverted (going from bottom to top).
control_scale : bool, default False
Whether to add a control scale on the map.
prefer_canvas : bool, default False
Forces Leaflet to use the Canvas back-end (if available) for vector layers instead of SVG. This can increase performance considerably in some cases (e.g. many thousands of circle markers on the map).
no_touch : bool, default False
Forces Leaflet to not use touch events even if it detects them.
disable_3d : bool, default False
Forces Leaflet to not use hardware-accelerated CSS 3D transforms for positioning (which may cause glitches in some rare environments) even if they're supported.
zoom_control : bool, default True
Display zoom controls on the map.
**kwargs
Additional keyword arguments are passed to Leaflets Map class: https://leafletjs.com/reference-1.6.0.html#map

Returns

Folium Map Object
 

Examples

>>> m = folium.Map(location=[45.523, -122.675], width=750, height=500)
>>> m = folium.Map(location=[45.523, -122.675], tiles='cartodb positron')
>>> m = folium.Map(
...    location=[45.523, -122.675],
...    zoom_start=2,
...    tiles='https://api.mapbox.com/v4/mapbox.streets/{z}/{x}/{y}.png?access_token=mytoken',
...    attr='Mapbox attribution'
...)

Methods

def write_file(self, f: , m: folium.folium.Map)