Category Histogram

The category histogram plot is used to show how frequently a set of discrete values (categories) occur.

Data Sourcing

Category histograms can be plotted using data from tables or arrays.

Creating a Category Histogram Plot using Data from a Table

When data is sourced from a table, the following syntax can be used:

.catHistPlot("seriesName", source, "ValueCol").show()

  • catHistPlot is the method used to create a category histogram.
  • "SeriesName" is the name (as a string) you want to use to identify the series on the chart itself.
  • source is the table that holds the data you want to plot.
  • "ValueCol" is the name of the column (as a string) containing the discrete values.
  • show tells Deephaven to draw the plot in the console.
tHist = db.t("LearnDeephaven", "StockTrades")
    .where("Date=`2017-08-25`")
    .view("Sym", "Last", "Size", "ExchangeTimestamp")

catHistTradesBySym = catHistPlot("Number of Trades", tHist, "Sym")
    .chartTitle("Trades per Symbol")
    .show()
from deephaven import Plot

tHist = db.t("LearnDeephaven", "StockTrades")\
    .where("Date=`2017-08-25`")\
    .view("Sym", "Last", "Size", "ExchangeTimestamp")

catHistTradesBySym = Plot.catHistPlot("Number of Trades", tHist, "Sym")\
    .chartTitle("Trades per Symbol")\
    .show()

This query plots the histogram as follows:

  • catHistTradesBySym is the name of the variable that will hold the plot.
  • catHistPlot is the method.
  • "Number of Trades" is the name of the series to use in the plot.
  • trades is the table from which our data is being pulled.
  • Sym is the name of the column containing the discrete values.
  • chartTitle("Trades per Symbol") adds a chart title to the plot.

img

Creating a Category Histogram Plot using Data from an Array

When data is sourced from an array, the following syntax can be used:

.catHistPlot("SeriesName", [Values]).show()

  • catHistPlot is the method used to create a category histogram.
  • "SeriesName" is the name (as a string) you want to use to identify the series on the plot itself.
  • [Values] is the array containing the discrete values.
  • show tells Deephaven to draw the plot in the console.

Additional Options