Skip to main content
Version: Java (Groovy)

Create category histograms

This guide shows you how to use the catHistPlot method to create category histograms, which is used to show how frequently a set of discrete values (categories) occur.

Data sourcing

From a table

When data is sourced from a Deephaven 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.
source = newTable(
intCol("Keys", 3, 2, 2, 1, 1, 1)
)

result = catHistPlot("Keys Count", source, "Keys")
.chartTitle("Count Of Each Key")
.show()

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.
def values = [3, 2, 2, 1, 1, 1] as int[]

result = catHistPlot("Values", values)
.chartTitle("Count Of Values")
.show()