vDataFrame.hchart (Beta)

In [ ]:
vDataFrame.hchart(x = None,
                  y = None,
                  z = None,
                  c = None,
                  aggregate: bool = True,
                  kind = "boxplot",
                  width: int = 600,
                  height: int = 400,
                  options: dict = {},
                  h: float = -1,
                  max_cardinality: int = 10,
                  limit: int = 10000,
                  drilldown: bool = False,
                  stock: bool = False,
                  alpha: float = 0.25)

Draws responsive charts using the High Chart API: https://api.highcharts.com/highcharts/

The returned object can be customized using the API parameters and the 'set_dict_options' method.

⚠ Warning: This function uses the unsupported HighChart Python API. For more information, see python-hicharts repository.

Parameters

Name Type Optional Description
x / y / z / c
str / list
The vcolumns and aggregations used to draw the chart. These will depend on the chart type. You can also specify an expression, but it must be a SQL statement. For example: AVG(column1) + SUM(column2) AS new_name.

    area / area_ts / line / spline

  • x : numerical or date type vcolumn
  • y : a single expression or list of expressions used to draw the plot
  • z : [OPTIONAL] vcolumn representing the different categories (only if y is a single vcolumn)

    area_range

  • x : numerical or date type vcolumn
  • y : list of three expressions [expression, lower bound, upper bound]

    bar (single) / donut / donut3d / hist (single) / pie / pie_half / pie3d

  • x : vcolumn used to compute the categories.
  • y : [OPTIONAL] numerical expression representing the categories values. If empty, COUNT(*) is used as the default aggregation.

    bar (double / drilldown) / hist (double / drilldown) / pie (drilldown) / stacked_bar / stacked_hist

  • x : vcolumn used to compute the first category.
  • y : vcolumn used to compute the second category.
  • z : [OPTIONAL] numerical expression representing the different categories values. If empty, COUNT(*) is used as the default aggregation.

    biserial / boxplot / pearson / kendall / pearson / spearman

  • x : list of the vcolumns used to draw the Chart.

    bubble / scatter

  • x : numerical vcolumn.
  • y : numerical vcolumn.
  • z : numerical vcolumn (bubble size in case of bubble plot, third dimension in case of scatter plot)
  • c : [OPTIONAL] vcolumn used to compute the different categories.

    candlestick

  • x : date type vcolumn.
  • y : Can be a numerical vcolumn or list of 5 expressions [last quantile, maximum, minimum, first quantile, volume]

    negative_bar

  • x : binary vcolumn used to compute the first category.
  • y : vcolumn used to compute the second category.
  • z : [OPTIONAL] numerical expression representing the categories values. If empty, COUNT(*) is used as the default aggregation.

    spider

  • x : vcolumn used to compute the different categories.
  • y : [OPTIONAL] Can be a list of the expressions used to draw the Plot or a single expression. If empty, COUNT(*) is used as the default aggregation.
aggregate
bool
If set to True, the input vcolumns will be aggregated.
kind
str
Chart Type.
  • area : Area Chart
  • area_range : Area Range Chart
  • area_ts : Area Chart with Time Series Design
  • bar : Bar Chart
  • biserial : Biserial Point Matrix (Correlation between binary variables and numerical)
  • boxplot : Box Plot
  • bubble : Bubble Plot
  • candlestick : Candlestick and Volumes (Time Series Special Plot)
  • cramer : Cramer's V Matrix (Correlation between categories)
  • donut : Donut Chart
  • donut3d : 3D Donut Chart
  • heatmap : Heatmap
  • hist : Histogram
  • kendall : Kendall Correlation Matrix. The method will compute the Tau-B coefficients.
    ⚠ Warning: This method is computationally expensive. It is using a CROSS JOIN during the computation. The complexity is O(n * n), n being the total count of the vDataFrame.
  • line : Line Plot
  • negative_bar : Multi Bar Chart for binary classes
  • pearson : Pearson Correlation Matrix
  • pie : Pie Chart
  • pie_half : Half Pie Chart
  • pie3d : 3D Pie Chart
  • scatter : Scatter Plot
  • spider : Spider Chart
  • spline : Spline Plot
  • stacked_bar : Stacked Bar Chart
  • stacked_hist : Stacked Histogram
  • spearman : Spearman Correlation Matrix
  • spearmannD : Spearman's correlation coefficient using the DENSE RANK function instead of the RANK function.
width
int
Chart Width.
height
int
Chart Height.
options
dict
High Chart Dictionary used to customize the Chart. Look at the API documentation to know the different options.
h
float
Interval width of the bar. If empty, an optimized value will be used.
max_cardinality
int
Maximum number of the vcolumn distinct elements.
limit
int
Maximum number of elements to draw.
drilldown
bool
Drilldown Chart: Only possible for Bars, Histograms, donuts and pies. Instead of drawing 2D charts, this option allows you to add a drilldown effect to 1D Charts.
stock
bool
Stock Chart: Only possible for Time Series. The design of the Time Series is dragable and have multiple options.
alpha
float
Value used to determine the position of the upper and lower quantile (Used when kind is set to 'candlestick')

Returns

Highchart : Chart Object

Example

In [22]:
from verticapy.datasets import *
titanic = load_titanic()
amazon = load_amazon()
iris = load_iris()
In [7]:
# Heatmap
titanic.hchart(x = "embarked",
               y = "pclass",
               z = "ROUND(AVG(survived), 2)",
               kind = "heatmap")
Out[7]:
In [8]:
# Correlation Matrix
titanic.hchart(kind = "pearson")
Out[8]:
In [21]:
# Boxplot
titanic.hchart(kind = "boxplot")
Out[21]:
In [11]:
# Bar
titanic.hchart(x = "pclass",
               y = "AVG(survived)",
               kind = "bar")
Out[11]:
In [20]:
# Hist with Drilldown
titanic.hchart(x = "embarked",
               y = "pclass",
               z = "ROUND(AVG(survived), 2)",
               kind = "hist",
               drilldown = True)
Out[20]:
In [26]:
# Pie with Drilldown
titanic.hchart(x = "embarked",
               y = "pclass",
               z = "ROUND(AVG(survived), 2)",
               kind = "pie",
               drilldown = True)
Out[26]:
In [19]:
# Area Range
amazon.search("YEAR(date) = 2014").hchart(
                          x = "date",
                          y = ["AVG(number) AS avg",
                               "MIN(number) AS min",
                               "MAX(number) AS max"],
                          kind = "area_range")
Out[19]:
In [25]:
# Candlestick
amazon.hchart("date",
              "number",
              kind = "candlestick",
              alpha = 0.05)
Out[25]:
In [23]:
# Scatter
iris.hchart(x = "PetalWidthCm",
            y = "PetalLengthCm",
            c = "Species",
            kind = "scatter")
Out[23]:
In [24]:
# Bubble
titanic.hchart(x = "age",
               y = "fare",
               z = "survived",
               c = "pclass",
               aggregate = False,
               kind = "bubble",
               limit = 20)
Out[24]: