Create pie charts
This guide shows you how to use the piePlot
method to create pie charts, which show data as sections of a circle to represent the relative proportion for each of the categories that make up the entire dataset being plotted.
Data sourcing
From a table
When data is sourced from a table, the following syntax can be used to create a pie plot:
.piePlot(seriesName, source, categoryCol, valueCol).show()
piePlot
is the method used to create a pie plot.seriesName
is the name (as a string) you want to use to identify the series on the plot itself.source
is the table that holds the data you want to plot.categoryCol
is the name of the column (as a string) to be used for the categories.valueCol
is the name of the column (as a string) to be used for the values.show
tells Deephaven to draw the plot in the console.
import static io.deephaven.csv.CsvTools.readCsv
totalInsurance = readCsv("https://media.githubusercontent.com/media/deephaven/examples/main/Insurance/csv/insurance.csv")
regionInsurance = totalInsurance.view("region", "expenses").sumBy("region")
pieChart = piePlot("Expense per region", regionInsurance, "region", "expenses")\
.chartTitle("Expenses per region")\
.show()
- totalInsurance
- regionInsurance
- pieChart