Create category histograms
This guide shows you how to use the plot_cat_hist
method to create category histograms, which is used to show how frequently a set of discrete values (categories) occur.
Basic category histogram
When data is sourced from a Deephaven table, the following syntax can be used:
.plot_cat_hist(series_name="series_name", t, category="Category").show()
plot_cat_hist
is the method used to create a category histogram.series_name
is the name (as a string) you want to use to identify the series on the chart itself.t
is the table that holds the data you want to plot.category
is the name of the column (as a string) containing the discrete values.show()
tells Deephaven to draw the plot in the console.
from deephaven import new_table
from deephaven.column import int_col
from deephaven.plot.figure import Figure
source = new_table([int_col("Keys", [3, 2, 2, 1, 1, 1])])
new_plot = (
Figure()
.plot_cat_hist(series_name="Category Histogram", t=source, category="Keys")
.show()
)
- source
- new_plot
From an array
When data is sourced from an array, the following syntax can be used:
.plot_cat_hist(series_name, category).show()
plot_cat_hist
is the method used to create a category histogram.series_name
is the name (as a string) you want to use to identify the series on the plot itself.category
is a list containing the discrete values.show
tells Deephaven to draw the plot in the console.
from deephaven.plot.figure import Figure
import numpy as np
values = np.array([3, 2, 2, 1, 1, 1])
new_plot = (
Figure()
.plot_cat_hist(series_name="Values", category=list(values))
.chart_title(title="Count of Values")
.show()
)
- new_plot