From the course: Data Science for Java Developers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Displaying a bar chart

Displaying a bar chart

- [Instructor] And now comes the time to actually define our graph that we're going to be displaying. So, we're going to start off by creating an axis called CategoryAxis and a CategoryAxis is different than a regular axis mainly just because we're using a BarChart, here. So we're going to say CategoryAxis xAxis = new CategoryAxis() and then we're going to say NumberAxis, this is the yAxis, here, NumberAxis yAxis = new NumberAxis(). And we're going to set the labels for our axis, here. We're going to say xAxis.setLabel and the label for that is going to be Number of cylinders, and the label for our yAxis is going to be Average mpg, okay. And next, we're going to create the BarChart itself now that we have those axis. So, we're going to say BarChart and this is going to be a String and a Number, as the generic types, since once axis is using a string, right, that's this thing, here, and the other one is using a number,…

Contents