corrgraph module

class corrgraph.CorrGraph(full_html=False, config=None)[source]

Bases: object

Class to generate various graphs and charts using the plotly library.

error() str[source]

Returns the last error message, if any.

Parameters:

accepted. (None is)

Returns:

Returns last error message of the module, if any.

Return type:

str

generateBarChart(data=[], x='', y=[], title='Dummy Title', orientation='v', color=None, hovername='', hoverdata=None, colormap=None, textauto=True, labels=None, rangex=None, showlegend=True) str[source]

Generate a bar chart from a data-set.

Parameters:
  • data (list) – The dataset to generate the bar-chart on. Each element is a dict with keyname-values and valuename-values ([{“KEYNAME”:”THENAME”,”VALUENAME”:”THEVALUE”},{}…N]).

  • x (list)

  • y (list)

  • title (str) – The title of the bar-chart.

  • orientation (str) – Sets the orientation of the bars in the bar-chart. Optional. Defaults to “v” for vertical. The other option is “h” for horizontal.

  • color – set which value in the data sets the various colors of the barchart. Defaults to None (not set).

  • hovername (str) – which variable is the name/top title of the popup for a data area.

  • hoverdata (list) – which variables are to be included in the popup for a data area.

  • colormap (dict) – set which “color”-parameter value has which color { “Norway”: “Blue”, “Sweden”: “Yellow” }. Defaults to None (not set and automatically generated)

  • textauto (bool) – set if the bars will have value on them or not?

  • labels (dict) – set legend for graph

  • rangex (list) – set the x-axis range to use. Eg. [0,100].

  • showlegend (bool) – show the legend or not for the graph. Defaults to True.

Returns:

Returns HTML code of the graph/chart generated if successful. None is returned otherwise.

Please use the error()-method to get more information upon a failure.

Return type:

str

generateBubbleChart(data, x='', y='', title='Dummy Title', size='', color='', rangex=None, rangey=None, hovername='', bubbletext=None, logx=False, maxsize=60, colormap=None, hoverdata=None, showlegend=True) str[source]

Wrapper around generateScatterGraph. Parameter text is changed to bubbletext - see generateScatterGraph

generateDonutChart(data=[], values='', names='', title='Dummy Title', onlyvalues=False, hole=0.3) str[source]

Wrapper around generatePieChart with hole-option set to non-zero as default (30%)

generateHorizontalBarChart(data=[], x='', y=[], title='Dummy Title', color=None, hovername='', hoverdata=None, colormap=None, textauto=True, labels=None, rangex=None, showlegend=True) str[source]
generatePieChart(data=[], values='', names='', title='Dummy Title', onlyvalues=False, hole=0, hovername='', hoverdata=None) str[source]

Creates a pie-chart from a data-set

Parameters:
  • data (list) – The dataset to generate the pie chart on. Each element is a dict with keyname-values and valuename-values ([{“KEYNAME”:”THENAME”,”VALUENAME”:”THEVALUE”},{}…N]).

  • values (str) – The key name that holds names of the piechart.

  • names (str) – The key name that holds the values of the piechart.

  • title (str) – The title of the piechart.

  • onlyvalues (bool) – Show only values on piechart, not percentage. Optional. Defaults to False.

  • hole (float) – The size of the hole in a pie-chart - which creates a donut-chart. Values is part of 1 (1=100%). Optional. Defaults to 0 (no hole - not a donut chart).

  • hovername (str) – which variable is the name/top title of the popup for a data area.

  • hoverdata (list) – which variables are to be included in the popup for a data area.

Returns:

Returns HTML code of the pie chart generated if successful. None is returned otherwise.

Please use the error()-method to get more information upon a failure.

Return type:

str

generateScatterGraph(data, x='', y='', title='Dummy Title', size='', color='', rangex=None, rangey=None, hovername='', text=None, logx=False, maxsize=1, colormap=None, hoverdata=None, showlegend=True) str[source]

Generate a scatter graph from a data-set.

Parameters:
  • data (list) – The dataset to generate the bar-chart on. Each element in the list is a dict. The dict is to contain the x- and y-data (set in the x- and y-arguments):

  • x (str) – Name of the x-axis. This name must also be used in the data, to give the value of the x-axis.

  • y (str) – Name of the y-axis. This name must also be used in the data, to give the value of the y-axis.

  • title (str) – The title of the scatter graph.

  • size (str) – Name of the key in an element in the data-list that gives the size attribute of the scatter graph (if set to a positive, non-zero value, it generates a bubble chart). Optional. Default to “”.

  • color (str) – The variable name of what defines the color of the bubbles (in a bubble chart). This variable must exist in the dict entries of the data-list.

  • rangex (list) – Gives the x-axis range of values that are acceptable. Can also be textual range. Must be given as a list with 2 elements, first element being “from” and the last being “to” in the range. If the textual range needs to include more than two elements, just specify the first two textual elements. Optional. Defaults to None (no range).

  • rangey (list) – Give the y-axis range of values that are acceptable. Functions the same as rangex - see above. Optional. Defaults to None (no range).

  • hovername (str) – is the variable name that defines the headline for the popup boxes over bubbles

  • text (str) – The variable name of the text to set on the bubble data points.

  • logx (bool) – sets if the x-axis is to be logarithmic or not?

  • maxsize (int) – Set the max size of bubbles in a bubble chart. Optional. Defaults to “”. If set, will attempt to generate a bubble chart.

  • colormap (dict) – Defines which colors are set for which values of the color-parameter (see above). {“Norway”: “Blue”, “Sweden”: “Yellow” }. Defaults to None.

  • hoverdata (list) – which variables are to be included in the popup boxes.

  • showlegend (bool) – sets if the legend is to be visible or not?

Returns:

Returns HTML code of the graph/chart generated if successful. None is returned otherwise.

Please use the error()-method to get more information upon a failure.

Return type:

str