plotly.figure_factory package¶
-
plotly.figure_factory.create_dendrogram(X, orientation='bottom', labels=None, colorscale=None, distfun=None, linkagefun=<function <lambda>>, hovertext=None, color_threshold=None)¶ Function that returns a dendrogram Plotly figure object. This is a thin wrapper around scipy.cluster.hierarchy.dendrogram.
See also https://dash.plot.ly/dash-bio/clustergram.
- Parameters
X ((ndarray)) – Matrix of observations as array of arrays
orientation ((str)) – ‘top’, ‘right’, ‘bottom’, or ‘left’
labels ((list)) – List of axis category labels(observation labels)
colorscale ((list)) – Optional colorscale for the dendrogram tree. Requires 8 colors to be specified, the 7th of which is ignored. With scipy>=1.5.0, the 2nd, 3rd and 6th are used twice as often as the others. Given a shorter list, the missing values are replaced with defaults and with a longer list the extra values are ignored.
distfun ((function)) – Function to compute the pairwise distance from the observations
linkagefun ((function)) – Function to compute the linkage matrix from the pairwise distances
hovertext ((list[list])) – List of hovertext for constituent traces of dendrogram clusters
color_threshold ((double)) – Value at which the separation of clusters will be made
Example 1: Simple bottom oriented dendrogram
>>> from plotly.figure_factory import create_dendrogram
>>> import numpy as np
>>> X = np.random.rand(10,10) >>> fig = create_dendrogram(X) >>> fig.show()
Example 2: Dendrogram to put on the left of the heatmap
>>> from plotly.figure_factory import create_dendrogram
>>> import numpy as np
>>> X = np.random.rand(5,5) >>> names = ['Jack', 'Oxana', 'John', 'Chelsea', 'Mark'] >>> dendro = create_dendrogram(X, orientation='right', labels=names) >>> dendro.update_layout({'width':700, 'height':500}) >>> dendro.show()
Example 3: Dendrogram with Pandas
>>> from plotly.figure_factory import create_dendrogram
>>> import numpy as np >>> import pandas as pd
>>> Index= ['A','B','C','D','E','F','G','H','I','J'] >>> df = pd.DataFrame(abs(np.random.randn(10, 10)), index=Index) >>> fig = create_dendrogram(df, labels=Index) >>> fig.show()
-
plotly.figure_factory.create_hexbin_map(data_frame=None, lat=None, lon=None, color=None, nx_hexagon=5, agg_func=None, animation_frame=None, color_discrete_sequence=None, color_discrete_map={}, labels={}, color_continuous_scale=None, range_color=None, color_continuous_midpoint=None, opacity=None, zoom=None, center=None, map_style=None, title=None, template=None, width=None, height=None, min_count=None, show_original_data=False, original_data_marker=None)¶ Returns a figure aggregating scattered points into connected hexagons
- Parameters
data_frame (DataFrame or array-like or dict) – This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are transformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constructed under the hood using the other arguments.
lat (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to position marks according to latitude on a map.lon (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to position marks according to longitude on a map.color (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to assign color to marks.nx_hexagon (int) – Number of hexagons (horizontally) to be created
agg_func (function) – Numpy array aggregator, it must take as input a 1D array and output a scalar value.
animation_frame (str or int or Series or array-like) – Either a name of a column in
data_frame, or a pandas Series or array_like object. Values from this column or array_like are used to assign marks to animation frames.color_discrete_sequence (list of str) – Strings should define valid CSS-colors. When
coloris set and the values in the corresponding column are not numeric, values in that column are assigned colors by cycling throughcolor_discrete_sequencein the order described incategory_orders, unless the value ofcoloris a key incolor_discrete_map. Various useful color sequences are available in theplotly.express.colorssubmodules, specificallyplotly.express.colors.qualitative.color_discrete_map (dict with str keys and str values (default
{})) – String values should define valid CSS-colors Used to overridecolor_discrete_sequenceto assign a specific colors to marks corresponding with specific values. Keys incolor_discrete_mapshould be values in the column denoted bycolor. Alternatively, if the values ofcolorare valid colors, the string'identity'may be passed to cause them to be used directly.labels (dict with str keys and str values (default
{})) – By default, column names are used in the figure for axis titles, legend entries and hovers. This parameter allows this to be overridden. The keys of this dict should correspond to column names, and the values should correspond to the desired label to be displayed.color_continuous_scale (list of str) – Strings should define valid CSS-colors This list is used to build a continuous color scale when the column denoted by
colorcontains numeric data. Various useful color scales are available in theplotly.express.colorssubmodules, specificallyplotly.express.colors.sequential,plotly.express.colors.divergingandplotly.express.colors.cyclical.range_color (list of two numbers) – If provided, overrides auto-scaling on the continuous color scale.
color_continuous_midpoint (number (default
None)) – If set, computes the bounds of the continuous color scale to have the desired midpoint. Setting this value is recommended when usingplotly.express.colors.divergingcolor scales as the inputs tocolor_continuous_scale.opacity (float) – Value between 0 and 1. Sets the opacity for markers.
zoom (int (default
None)) – Between 0 and 20. Sets initial map zoom level. Higher values are more zoomed-in. If not provided, the map will select its own zoom level.center (dict) – Dict keys are
'lat'and'lon'Sets the center point of the map.map_style (str (default
'basic')) – Identifier of base map style. Allowed values are'basic','carto-darkmatter','carto-darkmatter-nolabels','carto-positron','carto-positron-nolabels','carto-voyager','carto-voyager-nolabels','dark','light','open-street-map','outdoors','satellite','satellite-streets','streets','white-bg'.title (str) – The figure title.
template (str or dict or plotly.graph_objects.layout.Template instance) – The figure template name (must be a key in plotly.io.templates) or definition.
width (int (default
None)) – The figure width in pixels.height (int (default
None)) – The figure height in pixels.min_count (int) – Minimum number of points in a hexagon for it to be displayed. If None and color is not set, display all hexagons. If None and color is set, only display hexagons that contain points.
show_original_data (bool) – Whether to show the original data on top of the hexbin aggregation.
original_data_marker (dict) – Scattermap marker options.
- Returns
- Return type
-
plotly.figure_factory.create_quiver(x, y, u, v, scale=0.1, arrow_scale=0.3, angle=0.3490658503988659, scaleratio=None, **kwargs)¶ Returns data for a quiver plot.
- Parameters
x ((list|ndarray)) – x coordinates of the arrow locations
y ((list|ndarray)) – y coordinates of the arrow locations
u ((list|ndarray)) – x components of the arrow vectors
v ((list|ndarray)) – y components of the arrow vectors
in [0,1]) scale ((float) – scales size of the arrows(ideally to avoid overlap). Default = .1
in [0,1]) arrow_scale ((float) – value multiplied to length of barb to get length of arrowhead. Default = .3
in radians) angle ((angle) – angle of arrowhead. Default = pi/9
float) scaleratio ((positive) – the ratio between the scale of the y-axis and the scale of the x-axis (scale_y / scale_x). Default = None, the scale ratio is not fixed.
kwargs – kwargs passed through plotly.graph_objects.Scatter for more information on valid kwargs call help(plotly.graph_objects.Scatter)
- Rtype (dict)
returns a representation of quiver figure.
Example 1: Trivial Quiver
>>> from plotly.figure_factory import create_quiver >>> import math
>>> # 1 Arrow from (0,0) to (1,1) >>> fig = create_quiver(x=[0], y=[0], u=[1], v=[1], scale=1) >>> fig.show()
Example 2: Quiver plot using meshgrid
>>> from plotly.figure_factory import create_quiver
>>> import numpy as np >>> import math
>>> # Add data >>> x,y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2)) >>> u = np.cos(x)*y >>> v = np.sin(x)*y
>>> #Create quiver >>> fig = create_quiver(x, y, u, v) >>> fig.show()
Example 3: Styling the quiver plot
>>> from plotly.figure_factory import create_quiver >>> import numpy as np >>> import math
>>> # Add data >>> x, y = np.meshgrid(np.arange(-np.pi, math.pi, .5), ... np.arange(-math.pi, math.pi, .5)) >>> u = np.cos(x)*y >>> v = np.sin(x)*y
>>> # Create quiver >>> fig = create_quiver(x, y, u, v, scale=.2, arrow_scale=.3, angle=math.pi/6, ... name='Wind Velocity', line=dict(width=1))
>>> # Add title to layout >>> fig.update_layout(title='Quiver Plot') >>> fig.show()
Example 4: Forcing a fix scale ratio to maintain the arrow length
>>> from plotly.figure_factory import create_quiver >>> import numpy as np
>>> # Add data >>> x,y = np.meshgrid(np.arange(0.5, 3.5, .5), np.arange(0.5, 4.5, .5)) >>> u = x >>> v = y >>> angle = np.arctan(v / u) >>> norm = 0.25 >>> u = norm * np.cos(angle) >>> v = norm * np.sin(angle)
>>> # Create quiver with a fix scale ratio >>> fig = create_quiver(x, y, u, v, scale = 1, scaleratio = 0.5) >>> fig.show()
-
plotly.figure_factory.create_streamline(x, y, u, v, density=1, angle=0.3490658503988659, arrow_scale=0.09, **kwargs)¶ Returns data for a streamline plot.
- Parameters
x ((list|ndarray)) – 1 dimensional, evenly spaced list or array
y ((list|ndarray)) – 1 dimensional, evenly spaced list or array
u ((ndarray)) – 2 dimensional array
v ((ndarray)) – 2 dimensional array
density ((float|int)) – controls the density of streamlines in plot. This is multiplied by 30 to scale similiarly to other available streamline functions such as matplotlib. Default = 1
in radians) angle ((angle) – angle of arrowhead. Default = pi/9
in [0,1]) arrow_scale ((float) – value to scale length of arrowhead Default = .09
kwargs – kwargs passed through plotly.graph_objects.Scatter for more information on valid kwargs call help(plotly.graph_objects.Scatter)
- Rtype (dict)
returns a representation of streamline figure.
Example 1: Plot simple streamline and increase arrow size
>>> from plotly.figure_factory import create_streamline >>> import plotly.graph_objects as go >>> import numpy as np >>> import math
>>> # Add data >>> x = np.linspace(-3, 3, 100) >>> y = np.linspace(-3, 3, 100) >>> Y, X = np.meshgrid(x, y) >>> u = -1 - X**2 + Y >>> v = 1 + X - Y**2 >>> u = u.T # Transpose >>> v = v.T # Transpose
>>> # Create streamline >>> fig = create_streamline(x, y, u, v, arrow_scale=.1) >>> fig.show()
Example 2: from nbviewer.ipython.org/github/barbagroup/AeroPython
>>> from plotly.figure_factory import create_streamline >>> import numpy as np >>> import math
>>> # Add data >>> N = 50 >>> x_start, x_end = -2.0, 2.0 >>> y_start, y_end = -1.0, 1.0 >>> x = np.linspace(x_start, x_end, N) >>> y = np.linspace(y_start, y_end, N) >>> X, Y = np.meshgrid(x, y) >>> ss = 5.0 >>> x_s, y_s = -1.0, 0.0
>>> # Compute the velocity field on the mesh grid >>> u_s = ss/(2*np.pi) * (X-x_s)/((X-x_s)**2 + (Y-y_s)**2) >>> v_s = ss/(2*np.pi) * (Y-y_s)/((X-x_s)**2 + (Y-y_s)**2)
>>> # Create streamline >>> fig = create_streamline(x, y, u_s, v_s, density=2, name='streamline')
>>> # Add source point >>> point = go.Scatter(x=[x_s], y=[y_s], mode='markers', ... marker_size=14, name='source point')
>>> fig.add_trace(point) >>> fig.show()
-
plotly.figure_factory.create_table(table_text, colorscale=None, font_colors=None, index=False, index_title='', annotation_offset=0.45, height_constant=30, hoverinfo='none', **kwargs)¶ Function that creates data tables.
See also the plotly.graph_objects trace
plotly.graph_objects.Table- Parameters
| list[list]) text ((pandas.Dataframe) – data for table.
colorscale ((str|list[list])) – Colorscale for table where the color at value 0 is the header color, .5 is the first table color and 1 is the second table color. (Set .5 and 1 to avoid the striped table effect). Default=[[0, ‘#66b2ff’], [.5, ‘#d9d9d9’], [1, ‘#ffffff’]]
font_colors ((list)) – Color for fonts in table. Can be a single color, three colors, or a color for each row in the table. Default=[‘#000000’] (black text for the entire table)
height_constant ((int)) – Constant multiplied by # of rows to create table height. Default=30.
index ((bool)) – Create (header-colored) index column index from Pandas dataframe or list[0] for each list in text. Default=False.
index_title ((string)) – Title for index column. Default=’’.
kwargs – kwargs passed through plotly.graph_objects.Heatmap. These kwargs describe other attributes about the annotated Heatmap trace such as the colorscale. For more information on valid kwargs call help(plotly.graph_objects.Heatmap)
Example 1: Simple Plotly Table
>>> from plotly.figure_factory import create_table
>>> text = [['Country', 'Year', 'Population'], ... ['US', 2000, 282200000], ... ['Canada', 2000, 27790000], ... ['US', 2010, 309000000], ... ['Canada', 2010, 34000000]]
>>> table = create_table(text) >>> table.show()
Example 2: Table with Custom Coloring
>>> from plotly.figure_factory import create_table >>> text = [['Country', 'Year', 'Population'], ... ['US', 2000, 282200000], ... ['Canada', 2000, 27790000], ... ['US', 2010, 309000000], ... ['Canada', 2010, 34000000]] >>> table = create_table(text, ... colorscale=[[0, '#000000'], ... [.5, '#80beff'], ... [1, '#cce5ff']], ... font_colors=['#ffffff', '#000000', ... '#000000']) >>> table.show()
Example 3: Simple Plotly Table with Pandas
>>> from plotly.figure_factory import create_table >>> import pandas as pd >>> df = pd.read_csv('http://www.stat.ubc.ca/~jenny/notOcto/STAT545A/examples/gapminder/data/gapminderDataFiveYear.txt', sep=' ') >>> df_p = df[0:25] >>> table_simple = create_table(df_p) >>> table_simple.show()
-
plotly.figure_factory.create_ternary_contour(coordinates, values, pole_labels=['a', 'b', 'c'], width=500, height=500, ncontours=None, showscale=False, coloring=None, colorscale='Bluered', linecolor=None, title=None, interp_mode='ilr', showmarkers=False)¶ Ternary contour plot.
- Parameters
coordinates (list or ndarray) – Barycentric coordinates of shape (2, N) or (3, N) where N is the number of data points. The sum of the 3 coordinates is expected to be 1 for all data points.
values (array-like) – Data points of field to be represented as contours.
pole_labels (str, default ['a', 'b', 'c']) – Names of the three poles of the triangle.
width (int) – Figure width.
height (int) – Figure height.
ncontours (int or None) – Number of contours to display (determined automatically if None).
showscale (bool, default False) – If True, a colorbar showing the color scale is displayed.
coloring (None or 'lines') – How to display contour. Filled contours if None, lines if
lines.colorscale (None or str (Plotly colormap)) – colorscale of the contours.
linecolor (None or rgb color) – Color used for lines.
colorscalehas to be set to None, otherwise line colors are determined fromcolorscale.interp_mode ('ilr' (default) or 'cartesian') – Defines how data are interpolated to compute contours. If ‘irl’, ILR (Isometric Log-Ratio) of compositional data is performed. If ‘cartesian’, contours are determined in Cartesian space.
showmarkers (bool, default False) – If True, markers corresponding to input compositional points are superimposed on contours, using the same colorscale.
Examples
Example 1: ternary contour plot with filled contours
>>> import plotly.figure_factory as ff >>> import numpy as np >>> # Define coordinates >>> a, b = np.mgrid[0:1:20j, 0:1:20j] >>> mask = a + b <= 1 >>> a = a[mask].ravel() >>> b = b[mask].ravel() >>> c = 1 - a - b >>> # Values to be displayed as contours >>> z = a * b * c >>> fig = ff.create_ternary_contour(np.stack((a, b, c)), z) >>> fig.show()
It is also possible to give only two barycentric coordinates for each point, since the sum of the three coordinates is one:
>>> fig = ff.create_ternary_contour(np.stack((a, b)), z)
Example 2: ternary contour plot with line contours
>>> fig = ff.create_ternary_contour(np.stack((a, b, c)), z, coloring='lines')
Example 3: customize number of contours
>>> fig = ff.create_ternary_contour(np.stack((a, b, c)), z, ncontours=8)
Example 4: superimpose contour plot and original data as markers
>>> fig = ff.create_ternary_contour(np.stack((a, b, c)), z, coloring='lines', ... showmarkers=True)
Example 5: customize title and pole labels
>>> fig = ff.create_ternary_contour(np.stack((a, b, c)), z, ... title='Ternary plot', ... pole_labels=['clay', 'quartz', 'fledspar'])
-
plotly.figure_factory.create_trisurf(x, y, z, simplices, colormap=None, show_colorbar=True, scale=None, color_func=None, title='Trisurf Plot', plot_edges=True, showbackground=True, backgroundcolor='rgb(230, 230, 230)', gridcolor='rgb(255, 255, 255)', zerolinecolor='rgb(255, 255, 255)', edges_color='rgb(50, 50, 50)', height=800, width=800, aspectratio=None)¶ Returns figure for a triangulated surface plot
- Parameters
x ((array)) – data values of x in a 1D array
y ((array)) – data values of y in a 1D array
z ((array)) – data values of z in a 1D array
simplices ((array)) – an array of shape (ntri, 3) where ntri is the number of triangles in the triangularization. Each row of the array contains the indices of the vertices of each triangle
colormap ((str|tuple|list)) – either a plotly scale name, an rgb or hex color, a color tuple or a list of colors. An rgb color is of the form ‘rgb(x, y, z)’ where x, y, z belong to the interval [0, 255] and a color tuple is a tuple of the form (a, b, c) where a, b and c belong to [0, 1]. If colormap is a list, it must contain the valid color types aforementioned as its members
show_colorbar ((bool)) – determines if colorbar is visible
scale ((list|array)) – sets the scale values to be used if a non- linearly interpolated colormap is desired. If left as None, a linear interpolation between the colors will be excecuted
color_func ((function|list)) – The parameter that determines the coloring of the surface. Takes either a function with 3 arguments x, y, z or a list/array of color values the same length as simplices. If None, coloring will only depend on the z axis
title ((str)) – title of the plot
plot_edges ((bool)) – determines if the triangles on the trisurf are visible
showbackground ((bool)) – makes background in plot visible
backgroundcolor ((str)) – color of background. Takes a string of the form ‘rgb(x,y,z)’ x,y,z are between 0 and 255 inclusive
gridcolor ((str)) – color of the gridlines besides the axes. Takes a string of the form ‘rgb(x,y,z)’ x,y,z are between 0 and 255 inclusive
zerolinecolor ((str)) – color of the axes. Takes a string of the form ‘rgb(x,y,z)’ x,y,z are between 0 and 255 inclusive
edges_color ((str)) – color of the edges, if plot_edges is True
height ((int|float)) – the height of the plot (in pixels)
width ((int|float)) – the width of the plot (in pixels)
aspectratio ((dict)) – a dictionary of the aspect ratio values for the x, y and z axes. ‘x’, ‘y’ and ‘z’ take (int|float) values
Example 1: Sphere
>>> # Necessary Imports for Trisurf >>> import numpy as np >>> from scipy.spatial import Delaunay
>>> from plotly.figure_factory import create_trisurf >>> from plotly.graph_objects import graph_objects
>>> # Make data for plot >>> u = np.linspace(0, 2*np.pi, 20) >>> v = np.linspace(0, np.pi, 20) >>> u,v = np.meshgrid(u,v) >>> u = u.flatten() >>> v = v.flatten()
>>> x = np.sin(v)*np.cos(u) >>> y = np.sin(v)*np.sin(u) >>> z = np.cos(v)
>>> points2D = np.vstack([u,v]).T >>> tri = Delaunay(points2D) >>> simplices = tri.simplices
>>> # Create a figure >>> fig1 = create_trisurf(x=x, y=y, z=z, colormap="Rainbow", ... simplices=simplices)
Example 2: Torus
>>> # Necessary Imports for Trisurf >>> import numpy as np >>> from scipy.spatial import Delaunay
>>> from plotly.figure_factory import create_trisurf >>> from plotly.graph_objects import graph_objects
>>> # Make data for plot >>> u = np.linspace(0, 2*np.pi, 20) >>> v = np.linspace(0, 2*np.pi, 20) >>> u,v = np.meshgrid(u,v) >>> u = u.flatten() >>> v = v.flatten()
>>> x = (3 + (np.cos(v)))*np.cos(u) >>> y = (3 + (np.cos(v)))*np.sin(u) >>> z = np.sin(v)
>>> points2D = np.vstack([u,v]).T >>> tri = Delaunay(points2D) >>> simplices = tri.simplices
>>> # Create a figure >>> fig1 = create_trisurf(x=x, y=y, z=z, colormap="Viridis", ... simplices=simplices)
Example 3: Mobius Band
>>> # Necessary Imports for Trisurf >>> import numpy as np >>> from scipy.spatial import Delaunay
>>> from plotly.figure_factory import create_trisurf >>> from plotly.graph_objects import graph_objects
>>> # Make data for plot >>> u = np.linspace(0, 2*np.pi, 24) >>> v = np.linspace(-1, 1, 8) >>> u,v = np.meshgrid(u,v) >>> u = u.flatten() >>> v = v.flatten()
>>> tp = 1 + 0.5*v*np.cos(u/2.) >>> x = tp*np.cos(u) >>> y = tp*np.sin(u) >>> z = 0.5*v*np.sin(u/2.)
>>> points2D = np.vstack([u,v]).T >>> tri = Delaunay(points2D) >>> simplices = tri.simplices
>>> # Create a figure >>> fig1 = create_trisurf(x=x, y=y, z=z, colormap=[(0.2, 0.4, 0.6), (1, 1, 1)], ... simplices=simplices)
Example 4: Using a Custom Colormap Function with Light Cone
>>> # Necessary Imports for Trisurf >>> import numpy as np >>> from scipy.spatial import Delaunay
>>> from plotly.figure_factory import create_trisurf >>> from plotly.graph_objects import graph_objects
>>> # Make data for plot >>> u=np.linspace(-np.pi, np.pi, 30) >>> v=np.linspace(-np.pi, np.pi, 30) >>> u,v=np.meshgrid(u,v) >>> u=u.flatten() >>> v=v.flatten()
>>> x = u >>> y = u*np.cos(v) >>> z = u*np.sin(v)
>>> points2D = np.vstack([u,v]).T >>> tri = Delaunay(points2D) >>> simplices = tri.simplices
>>> # Define distance function >>> def dist_origin(x, y, z): ... return np.sqrt((1.0 * x)**2 + (1.0 * y)**2 + (1.0 * z)**2)
>>> # Create a figure >>> fig1 = create_trisurf(x=x, y=y, z=z, ... colormap=['#FFFFFF', '#E4FFFE', ... '#A4F6F9', '#FF99FE', ... '#BA52ED'], ... scale=[0, 0.6, 0.71, 0.89, 1], ... simplices=simplices, ... color_func=dist_origin)
Example 5: Enter color_func as a list of colors
>>> # Necessary Imports for Trisurf >>> import numpy as np >>> from scipy.spatial import Delaunay >>> import random
>>> from plotly.figure_factory import create_trisurf >>> from plotly.graph_objects import graph_objects
>>> # Make data for plot >>> u=np.linspace(-np.pi, np.pi, 30) >>> v=np.linspace(-np.pi, np.pi, 30) >>> u,v=np.meshgrid(u,v) >>> u=u.flatten() >>> v=v.flatten()
>>> x = u >>> y = u*np.cos(v) >>> z = u*np.sin(v)
>>> points2D = np.vstack([u,v]).T >>> tri = Delaunay(points2D) >>> simplices = tri.simplices
>>> colors = [] >>> color_choices = ['rgb(0, 0, 0)', '#6c4774', '#d6c7dd']
>>> for index in range(len(simplices)): ... colors.append(random.choice(color_choices))
>>> fig = create_trisurf( ... x, y, z, simplices, ... color_func=colors, ... show_colorbar=True, ... edges_color='rgb(2, 85, 180)', ... title=' Modern Art' ... )
Submodules¶
plotly.figure_factory.utils module¶
-
plotly.figure_factory.utils.annotation_dict_for_label(text, lane, num_of_lanes, subplot_spacing, row_col='col', flipped=True, right_side=True, text_color='#0f0f0f')¶ Returns annotation dict for label of n labels of a 1xn or nx1 subplot.
- Parameters
text ((str)) – the text for a label.
lane ((int)) – the label number for text. From 1 to n inclusive.
num_of_lanes ((int)) – the number ‘n’ of rows or columns in subplot.
subplot_spacing ((float)) – the value for the horizontal_spacing and vertical_spacing params in your plotly.tools.make_subplots() call.
row_col ((str)) – choose whether labels are placed along rows or columns.
flipped ((bool)) – flips text by 90 degrees. Text is printed horizontally if set to True and row_col=’row’, or if False and row_col=’col’.
right_side ((bool)) – only applicable if row_col is set to ‘row’.
text_color ((str)) – color of the text.
-
plotly.figure_factory.utils.endpts_to_intervals(endpts)¶ Returns a list of intervals for categorical colormaps
Accepts a list or tuple of sequentially increasing numbers and returns a list representation of the mathematical intervals with these numbers as endpoints. For example, [1, 6] returns [[-inf, 1], [1, 6], [6, inf]]
- Raises
(PlotlyError) If input is not a list or tuple
- Raises
(PlotlyError) If the input contains a string
- Raises
(PlotlyError) If any number does not increase after the previous one in the sequence
-
plotly.figure_factory.utils.flatten(array)¶ Uses list comprehension to flatten array
- Parameters
(array) – An iterable to flatten
- Raises
(PlotlyError) – If iterable is not nested.
- Rtype (list)
The flattened list.
-
plotly.figure_factory.utils.is_sequence(obj)¶
-
plotly.figure_factory.utils.list_of_options(iterable, conj='and', period=True)¶ Returns an English listing of objects separated by commas ‘,’
For example, [‘foo’, ‘bar’, ‘baz’] becomes ‘foo, bar and baz’ if the conjunction ‘and’ is selected.
-
plotly.figure_factory.utils.validate_dataframe(array)¶ Validates all strings or numbers in each dataframe column
- Raises
(PlotlyError) If there are any two items in any list whose types differ
-
plotly.figure_factory.utils.validate_equal_length(*args)¶ Validates that data lists or ndarrays are the same length.
- Raises
(PlotlyError) If any data lists are not the same length.
-
plotly.figure_factory.utils.validate_index(index_vals)¶ Validates if a list contains all numbers or all strings
- Raises
(PlotlyError) If there are any two items in the list whose types differ
-
plotly.figure_factory.utils.validate_positive_scalars(**kwargs)¶ Validates that all values given in key/val pairs are positive.
Accepts kwargs to improve Exception messages.
- Raises
(PlotlyError) If any value is < 0 or raises.
