A third-party Java wrapper for plotly.js
Plotly.java is a third-party Java wrapper for the Plotly JavaScript open source graphing library, one of the finest graphing libraries available. plotly.java lets you generate a wide range of JavaScript/HTML charts.
Plotly.java was developed as part of the Tablesaw Java dataframe library. Dependencies on Tablesaw have now been removed to make it easier to incorporate visualizations into a broad range of Java applications.
package tech.tablesaw.examples;
import tech.tablesaw.plotly.Plot;
import tech.tablesaw.plotly.components.Figure;
import tech.tablesaw.plotly.components.Layout;
import tech.tablesaw.plotly.traces.ScatterTrace;
public class AreaPlotExample {
/** Creates a simple area plot with an index (observation number) x axis */
public static void main(String[] args) throws Exception {
String title = "Boston Robberies: 1966-1975";
double[] observation = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0};
double[] count = {41.0, 39.0, 50.0, 40.0, 43.0, 38.0, 44.0, 35.0, 39.0, 35.0, 29.0, 49.0};
Layout layout = Layout.builder(title, "Month", "Robberies").build();
ScatterTrace trace =
ScatterTrace.builder(observation, count)
.mode(ScatterTrace.Mode.LINE)
.fill(ScatterTrace.Fill.TO_NEXT_Y)
.fillColor("#b987fb")
.build();
Plot.show(new Figure(layout, trace));
}
}
Add tablesaw-plotly-java to your project. You can find the version number for the latest release in the release notes:
<dependency>
<groupId>tech.tablesaw</groupId>
<artifactId>tablesaw-plotly-java</artifactId>
<version>VERSION_NUMBER_GOES_HERE</version>
</dependency>