use of tech.tablesaw.plotly.traces.BarTrace in project tablesaw by jtablesaw.
the class ParetoExample method main.
public static void main(String[] args) throws Exception {
Table table = Table.read().csv("../data/tornadoes_1950-2014.csv");
table = table.where(table.numberColumn("Fatalities").isGreaterThan(3));
Table t2 = table.summarize("fatalities", sum).by("State");
t2 = t2.sortDescendingOn(t2.column(1).name());
Layout layout = Layout.builder().title("Tornado Fatalities by State").build();
BarTrace trace = BarTrace.builder(t2.categoricalColumn(0), t2.numberColumn(1)).build();
Plot.show(new Figure(layout, trace));
}
use of tech.tablesaw.plotly.traces.BarTrace in project tablesaw by jtablesaw.
the class PageTest method testCustomPlotlyJsLocation.
@Test
public void testCustomPlotlyJsLocation() {
BarTrace trace = BarTrace.builder(x, y).build();
String location = this.getClass().getResource(this.getClass().getSimpleName() + ".class").toString();
Page page = Page.pageBuilder(new Figure(trace), "plot").plotlyJsLocation(location).build();
String html = page.asJavascript();
assertTrue(html.indexOf("\"" + location + "\"") > 0);
}
use of tech.tablesaw.plotly.traces.BarTrace in project tablesaw by jtablesaw.
the class BarPieAndParetoExample method main.
public static void main(String[] args) throws Exception {
// ***************** Setup *************************
// load the data into a table
Table tornadoes = Table.read().csv("../data/tornadoes_1950-2014.csv");
// Get the scale column and replace any values of -9 with the column's missing value indicator
IntColumn scale = tornadoes.intColumn("scale");
scale.set(scale.isEqualTo(-9), IntColumnType.missingValueIndicator());
// ***************** Plotting **********************
// BAR PLOTS
// Sum the number of fatalities from each tornado, grouping by scale
Table fatalities1 = tornadoes.summarize("fatalities", sum).by("scale");
// Plot
Plot.show(HorizontalBarPlot.create(// plot title
"fatalities by scale", // table
fatalities1, // grouping column name
"scale", // numeric column name
"sum [fatalities]"));
// Plot the mean injuries rather than a sum.
Table injuries1 = tornadoes.summarize("injuries", mean).by("scale");
Plot.show(HorizontalBarPlot.create("Average number of tornado injuries by scale", injuries1, "scale", "mean [injuries]"));
// PIE PLOT
Plot.show(PiePlot.create("fatalities by scale", fatalities1, "scale", "sum [fatalities]"));
// PARETO PLOT
Table t2 = tornadoes.summarize("fatalities", sum).by("State");
t2 = t2.sortDescendingOn(t2.column(1).name());
Layout layout = Layout.builder().title("Tornado Fatalities by State").build();
BarTrace trace = BarTrace.builder(t2.categoricalColumn(0), t2.numberColumn(1)).build();
Plot.show(new Figure(layout, trace));
}
use of tech.tablesaw.plotly.traces.BarTrace in project tablesaw by jtablesaw.
the class BarTest method show.
@Test
public void show() {
BarTrace trace = BarTrace.builder(x, y).build();
Figure figure = new Figure(trace);
Plot.show(figure, "target");
}
use of tech.tablesaw.plotly.traces.BarTrace in project tablesaw by jtablesaw.
the class BarTest method testAsJavascript.
@Test
public void testAsJavascript() {
BarTrace trace = BarTrace.builder(x, y).build();
System.out.println(trace.asJavascript(1));
}
Aggregations