Search in sources :

Example 91 with Figure

use of tech.tablesaw.plotly.components.Figure in project tablesaw by jtablesaw.

the class HorizontalBarExample method main.

public static void main(String[] args) throws Exception {
    Table table = Table.read().csv("../data/tornadoes_1950-2014.csv");
    Table s = table.summarize("fatalities", count).by("State");
    BarTrace trace = BarTrace.builder(s.categoricalColumn(0), s.numberColumn(1)).orientation(BarTrace.Orientation.HORIZONTAL).build();
    Layout layout = Layout.builder().title("Tornadoes by state").height(600).width(800).build();
    Plot.show(new Figure(layout, trace));
}
Also used : Table(tech.tablesaw.api.Table) BarTrace(tech.tablesaw.plotly.traces.BarTrace) Layout(tech.tablesaw.plotly.components.Layout) Figure(tech.tablesaw.plotly.components.Figure)

Example 92 with Figure

use of tech.tablesaw.plotly.components.Figure in project tablesaw by jtablesaw.

the class TimeSeriesPlot method create.

public static Figure create(String title, Table table, String dateColX, String yCol, String groupCol) {
    TableSliceGroup tables = table.splitOn(table.categoricalColumn(groupCol));
    Layout layout = Layout.builder(title, dateColX, yCol).build();
    ScatterTrace[] traces = new ScatterTrace[tables.size()];
    for (int i = 0; i < tables.size(); i++) {
        List<Table> tableList = tables.asTableList();
        Table t = tableList.get(i).sortOn(dateColX);
        traces[i] = ScatterTrace.builder(t.dateColumn(dateColX), t.numberColumn(yCol)).showLegend(true).name(tableList.get(i).name()).mode(ScatterTrace.Mode.LINE).build();
    }
    return new Figure(layout, traces);
}
Also used : Table(tech.tablesaw.api.Table) Layout(tech.tablesaw.plotly.components.Layout) TableSliceGroup(tech.tablesaw.table.TableSliceGroup) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Aggregations

Figure (tech.tablesaw.plotly.components.Figure)92 Layout (tech.tablesaw.plotly.components.Layout)72 ScatterTrace (tech.tablesaw.plotly.traces.ScatterTrace)53 Table (tech.tablesaw.api.Table)35 Test (org.junit.jupiter.api.Test)20 Trace (tech.tablesaw.plotly.traces.Trace)20 BarTrace (tech.tablesaw.plotly.traces.BarTrace)9 HistogramTrace (tech.tablesaw.plotly.traces.HistogramTrace)8 IntColumn (tech.tablesaw.api.IntColumn)7 File (java.io.File)6 TableSliceGroup (tech.tablesaw.table.TableSliceGroup)6 Marker (tech.tablesaw.plotly.components.Marker)4 Scatter3DTrace (tech.tablesaw.plotly.traces.Scatter3DTrace)4 ArrayList (java.util.ArrayList)3 Page (tech.tablesaw.plotly.components.Page)3 BoxTrace (tech.tablesaw.plotly.traces.BoxTrace)3 PieTrace (tech.tablesaw.plotly.traces.PieTrace)3 ViolinTrace (tech.tablesaw.plotly.traces.ViolinTrace)3 StringColumn (tech.tablesaw.api.StringColumn)2 Column (tech.tablesaw.columns.Column)2