cufflinks.tools module¶
-
cufflinks.tools.
axis
¶
-
cufflinks.tools.
figures
(df, specs, asList=False)[source]¶ Generates multiple Plotly figures for a given DataFrame
- df : DataFrame
- Pandas DataFrame
- specs : list(dict)
- List of dictionaries with the properties of each figure. All properties avaialbe can be seen with help(cufflinks.pd.DataFrame.iplot)
- asList : boolean
- If True, then a list of figures is returned. Otherwise a single (merged) figure is returned. Default : False
-
cufflinks.tools.
getAnnotations
(df, annotations, kind='lines', theme=None, **kwargs)[source]¶ Generates an annotations object
- df : DataFrame
- Original DataFrame of values
- annotations : dict or list
- Dictionary of annotations {x_point : text} or List of Plotly annotations
-
cufflinks.tools.
getLayout
(kind=None, theme=None, title='', xTitle='', yTitle='', zTitle='', barmode='', bargap=None, bargroupgap=None, margin=None, dimensions=None, width=None, height=None, annotations=None, is3d=False, **kwargs)[source]¶ Generates a plotly Layout
- theme : string
- Layout Theme
- solar pearl white
- title : string
- Chart Title
- xTitle : string
- X Axis Title
- yTitle : string
- Y Axis Title
- zTitle : string
- Z Axis Title Applicable only for 3d charts
- barmode : string
- Mode when displaying bars
- group stack overlay
- bargap : float
- Sets the gap between bars
- [0,1)
Applicabe for bar and histogram plots
- bargroupgap : float
- Set the gap between groups
- [0,1)
Applicabe for bar and histogram plots
- gridcolor : string
- grid color
- zerolinecolor : string
- zero line color
- margin : dict or tuple
- Dictionary (l,r,b,t) or Tuple containing the left, right, bottom and top margins
- dimensions : tuple
- Dimensions of figure
- annotations : dict or list
- Dictionary of annotations
- {x_point : text}
or List of Plotly Annotations
- is3d : bool
- Indicates if the layout is for a 3D chart
- Shapes
- hline : int, list or dict
- Draws a horizontal line at the indicated y position(s) Extra parameters can be passed in the form of a dictionary (see shapes)
- vline : int, list or dict
- Draws a vertical line at the indicated x position(s) Extra parameters can be passed in the form of a dictionary (see shapes)
- hspan : (y0,y1)
- Draws a horizontal rectangle at the indicated (y0,y1) positions. Extra parameters can be passed in the form of a dictionary (see shapes)
- vspan : (x0,x1)
- Draws a vertical rectangle at the indicated (x0,x1) positions. Extra parameters can be passed in the form of a dictionary (see shapes)
- shapes : dict or list(dict)
- List of dictionaries with the specifications of a given shape. See help(cufflinks.tools.get_shape) for more information
- Axis Ranges
- xrange : [lower_bound,upper_bound]
- Sets the range for the x axis
- yrange : [lower_bound,upper_bound]
- Sets the range for the y axis
- zrange : [lower_bound,upper_bound]
- Sets the range for the z axis
- Explicit Layout Updates
- layout_update : dict
- The layout will be modified with all the explicit values stated in the dictionary
- Range Selector
- rangeselector : dict
Defines a rangeselector object see help(cf.tools.get_range_selector) for more information Example:
- {‘steps’:[‘1y’,‘2 months’,‘5 weeks’,’ytd’,‘2mtd’],
- ‘axis’:’xaxis1’, ‘bgcolor’ : (‘blue’,.3), ‘x’: 0.2 , ‘y’ : 0.9}
- Range Slider
- rangeslider : bool or dict
Defines if a rangeslider is displayed If bool:
True : Makes it visible- if dict:
- Rangeslider object
- Example:
- {‘bgcolor’:(‘blue’,.3),’autorange’:True}
- Annotations
- fontcolor : str
- Text color for annotations
- fontsize : int
- Text size for annotations
- textangle : int
- Textt angle
See https://plot.ly/python/reference/#layout-annotations for a complete list of valid parameters.
-
cufflinks.tools.
getTheme
(theme=None)[source]¶ Returns a theme definition.
To see the colors translated (hex) use cufflinks.getLayout(theme) instead.
-
cufflinks.tools.
get_base_layout
(figs)[source]¶ Generates a layout with the union of all properties of multiple figures’ layouts
- fig : list(Figures)
- List of Plotly Figures
-
cufflinks.tools.
get_candle
(df, up_color=None, down_color=None, theme=None, layout=None, **kwargs)[source]¶
-
cufflinks.tools.
get_error_bar
(axis='y', type='data', values=None, values_minus=None, color=None, thickness=1, width=5, opacity=1)[source]¶
-
cufflinks.tools.
get_ohlc
(df, up_color=None, down_color=None, theme=None, layout=None, **kwargs)[source]¶
-
cufflinks.tools.
get_range_selector
(steps=['1m', '1y'], bgcolor='rgba(150, 200, 250, 0.4)', x=0, y=0.9, visible=True, **kwargs)[source]¶ Returns a range selector Reference: https://plot.ly/python/reference/#layout-xaxis-rangeselector
- steps : string or list(string)
- Steps for the range
- Examples:
- [‘1y’,‘2 months’,‘5 weeks’,’ytd’,‘2mtd’]
- bgocolor : string or tuple(color,alpha)
- Background color
- Examples:
- ‘cyan’ ‘rgba(232,214,10,.5)’ (‘blue’,.3)
- font_size : int
- Font size
- x : float
- Position along the x axis Domain (0,1)
- y : float
- Position along the y axis Domain (0,1)
-
cufflinks.tools.
get_shape
(kind='line', x=None, y=None, x0=None, y0=None, x1=None, y1=None, span=0, color='red', dash='solid', width=1, fillcolor=None, fill=False, opacity=1, xref='x', yref='y')[source]¶ Returns a plotly shape
- kind : string
- Shape kind
- line rect circle
- x : float
- x values for the shape. This assumes x0=x1
- x0 : float
- x0 value for the shape
- x1 : float
- x1 value for the shape
- y : float
- y values for the shape. This assumes y0=y1
- y0 : float
- y0 value for the shape
- y1 : float
- y1 value for the shape
- color : string
- color for shape line
- dash : string
- line style
- solid dash dashdot dot
- width : int
- line width
- fillcolor : string
- shape fill color
- fill : bool
- If True then fill shape If not fillcolor then the line color will be used
- opacity : float [0,1]
- opacity of the fill
- xref : string
Sets the x coordinate system which this object refers to
‘x’ ‘paper’ ‘x2’ etc- yref : string
Sets the y coordinate system which this object refers to
‘y’ ‘paper’ ‘y2’ etc
-
cufflinks.tools.
get_subplots
(rows=1, cols=1, shared_xaxes=False, shared_yaxes=False, start_cell='top-left', theme=None, base_layout=None, **kwargs)[source]¶ Generates a subplot view for a set of figures
- rows : int
- Number of rows
- cols : int
- Number of cols
- shared_xaxes : bool
- Assign shared x axes. If True, subplots in the same grid column have one common shared x-axis at the bottom of the gird.
- shared_yaxes : bool
- Assign shared y axes. If True, subplots in the same grid row have one common shared y-axis on the left-hand side of the gird.
- start_cell : string
- ‘bottom-left’ ‘top-left’
Choose the starting cell in the subplot grid used to set the domains of the subplots.
- theme : string
- Layout Theme
- solar pearl white
see cufflinks.getThemes() for all available themes
- horizontal_spacing : float
- [0,1]
Space between subplot columns.
- vertical_spacing : float
- Space between subplot rows.
- specs : list of dicts
- Subplot specifications.
- ex1: specs=[[{}, {}], [{‘colspan’: 2}, None]] ex2: specs=[[{‘rowspan’: 2}, {}], [None, {}]]
- Indices of the outer list correspond to subplot grid rows starting from the bottom. The number of rows in ‘specs’ must be equal to ‘rows’.
- Indices of the inner lists correspond to subplot grid columns starting from the left. The number of columns in ‘specs’ must be equal to ‘cols’.
- Each item in the ‘specs’ list corresponds to one subplot in a subplot grid. (N.B. The subplot grid has exactly ‘rows’ times ‘cols’ cells.)
- Use None for blank a subplot cell (or to move pass a col/row span).
- Note that specs[0][0] has the specs of the ‘start_cell’ subplot.
- Each item in ‘specs’ is a dictionary.
- The available keys are:
- is_3d (boolean, default=False): flag for 3d scenes
- colspan (int, default=1): number of subplot columns
- for this subplot to span.
- rowspan (int, default=1): number of subplot rows
- for this subplot to span.
- l (float, default=0.0): padding left of cell
- r (float, default=0.0): padding right of cell
- t (float, default=0.0): padding right of cell
- b (float, default=0.0): padding bottom of cell
- Use ‘horizontal_spacing’ and ‘vertical_spacing’ to adjust the spacing in between the subplots.
- insets : list of dicts
Inset specifications.
- Each item in ‘insets’ is a dictionary.
- The available keys are:
- cell (tuple, default=(1,1)): (row, col) index of the
- subplot cell to overlay inset axes onto.
- is_3d (boolean, default=False): flag for 3d scenes
- l (float, default=0.0): padding left of inset
- in fraction of cell width
- w (float or ‘to_end’, default=’to_end’) inset width
- in fraction of cell width (‘to_end’: to cell right edge)
- b (float, default=0.0): padding bottom of inset
- in fraction of cell height
- h (float or ‘to_end’, default=’to_end’) inset height
- in fraction of cell height (‘to_end’: to cell top edge)
-
cufflinks.tools.
merge_figures
(figures)[source]¶ Generates a single Figure from a list of figures
- figures : list(Figures)
- List of figures to be merged.
-
cufflinks.tools.
scatter_matrix
(df, theme=None, bins=10, color='grey', size=2)[source]¶ Displays a matrix with scatter plot for each pair of Series in the DataFrame. The diagonal shows a histogram for each of the Series
- df : DataFrame
- Pandas DataFrame
- theme : string
- Theme to be used (if not the default)
- bins : int
- Number of bins to use for histogram
- color : string
- Color to be used for each scatter plot
- size : int
- Size for each marker on the scatter plot
-
cufflinks.tools.
set_errors
(figure, trace=None, axis='y', type='data', values=None, values_minus=None, color=None, thickness=1, width=None, opacity=None, **kwargs)[source]¶
-
cufflinks.tools.
strip_figures
(figure)[source]¶ Strips a figure into multiple figures with a trace on each of them
- figure : Figure
- Plotly Figure
-
cufflinks.tools.
subplots
(figures, shape=None, shared_xaxes=False, shared_yaxes=False, start_cell='top-left', theme=None, base_layout=None, **kwargs)[source]¶ Generates a subplot view for a set of figures This is a wrapper for plotly.tools.make_subplots
- figures : [Figures]
- List of Plotly Figures
- shape : (rows,cols)
- Tuple indicating the size of rows and columns If omitted then the layout is automatically set
- shared_xaxes : bool
- Assign shared x axes. If True, subplots in the same grid column have one common shared x-axis at the bottom of the grid.
- shared_yaxes : bool
- Assign shared y axes. If True, subplots in the same grid row have one common shared y-axis on the left-hand side of the grid.
- start_cell : string
- ‘bottom-left’ ‘top-left’
Choose the starting cell in the subplot grid used to set the domains of the subplots.
- theme : string
- Layout Theme
- solar pearl white
see cufflinks.getThemes() for all available themes
- base_layout : layout (dict)
- Layout to be used as base where the subplots will be added
- subplot_titles : list(string)
- List of strings that contains the titles of each plot.
- horizontal_spacing : float
- [0,1]
Space between subplot columns.
- vertical_spacing : float
- Space between subplot rows.
- specs : list of dicts
- Subplot specifications.
- ex1: specs=[[{}, {}], [{‘colspan’: 2}, None]] ex2: specs=[[{‘rowspan’: 2}, {}], [None, {}]]
- Indices of the outer list correspond to subplot grid rows starting from the bottom. The number of rows in ‘specs’ must be equal to ‘rows’.
- Indices of the inner lists correspond to subplot grid columns starting from the left. The number of columns in ‘specs’ must be equal to ‘cols’.
- Each item in the ‘specs’ list corresponds to one subplot in a subplot grid. (N.B. The subplot grid has exactly ‘rows’ times ‘cols’ cells.)
- Use None for blank a subplot cell (or to move pass a col/row span).
- Note that specs[0][0] has the specs of the ‘start_cell’ subplot.
- Each item in ‘specs’ is a dictionary.
- The available keys are:
- is_3d (boolean, default=False): flag for 3d scenes
- colspan (int, default=1): number of subplot columns
- for this subplot to span.
- rowspan (int, default=1): number of subplot rows
- for this subplot to span.
- l (float, default=0.0): padding left of cell
- r (float, default=0.0): padding right of cell
- t (float, default=0.0): padding right of cell
- b (float, default=0.0): padding bottom of cell
- Use ‘horizontal_spacing’ and ‘vertical_spacing’ to adjust the spacing in between the subplots.
- insets : list of dicts
Inset specifications.
- Each item in ‘insets’ is a dictionary.
- The available keys are:
- cell (tuple, default=(1,1)): (row, col) index of the
- subplot cell to overlay inset axes onto.
- is_3d (boolean, default=False): flag for 3d scenes
- l (float, default=0.0): padding left of inset
- in fraction of cell width
- w (float or ‘to_end’, default=’to_end’) inset width
- in fraction of cell width (‘to_end’: to cell right edge)
- b (float, default=0.0): padding bottom of inset
- in fraction of cell height
- h (float or ‘to_end’, default=’to_end’) inset height
- in fraction of cell height (‘to_end’: to cell top edge)
-
cufflinks.tools.
trace_dict
¶