Search in sources :

Example 1 with Marker

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

the class Scatter3DPlot method create.

public static Figure create(String title, Table table, String xCol, String yCol, String zCol, String sizeColumn, String groupCol) {
    TableSliceGroup tables = table.splitOn(table.categoricalColumn(groupCol));
    Layout layout = standardLayout(title, xCol, yCol, zCol, false);
    Scatter3DTrace[] traces = new Scatter3DTrace[tables.size()];
    for (int i = 0; i < tables.size(); i++) {
        List<Table> tableList = tables.asTableList();
        Marker marker = Marker.builder().size(tableList.get(i).numberColumn(sizeColumn)).build();
        traces[i] = Scatter3DTrace.builder(tableList.get(i).numberColumn(xCol), tableList.get(i).numberColumn(yCol), tableList.get(i).numberColumn(zCol)).marker(marker).showLegend(true).name(tableList.get(i).name()).build();
    }
    return new Figure(layout, traces);
}
Also used : Table(tech.tablesaw.api.Table) Layout(tech.tablesaw.plotly.components.Layout) Scatter3DTrace(tech.tablesaw.plotly.traces.Scatter3DTrace) Marker(tech.tablesaw.plotly.components.Marker) TableSliceGroup(tech.tablesaw.table.TableSliceGroup) Figure(tech.tablesaw.plotly.components.Figure)

Example 2 with Marker

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

the class MarkerTest method asJavascript.

@Test
public void asJavascript() {
    Marker x = Marker.builder().size(12.0).symbol(Symbol.DIAMOND_TALL).color("#c68486").build();
    assertTrue(x.asJavascript().contains("color"));
    assertTrue(x.asJavascript().contains("symbol"));
    assertTrue(x.asJavascript().contains("size"));
}
Also used : Marker(tech.tablesaw.plotly.components.Marker) Test(org.junit.jupiter.api.Test)

Example 3 with Marker

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

the class BubblePlot method create.

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

Example 4 with Marker

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

the class BubblePlot method create.

/**
 * create a bubble plot using more options including color/sizeMode/opacity
 *
 * @param title plot title
 * @param xColumn non-nullable, column data for x-axis
 * @param yColumn non-nullable, column data for y-axis
 * @param sizeColumn nullable, indicate the bubble size
 * @param color color for every data point
 * @param sizeMode check {@link SizeMode}
 * @param opacity display opacity
 * @return bubble plot created from given parameters
 */
public static Figure create(String title, Column xColumn, Column yColumn, NumericColumn sizeColumn, double[] color, SizeMode sizeMode, Double opacity) {
    Layout layout = Layout.builder(title, xColumn.name(), yColumn.name()).build();
    Marker marker = null;
    MarkerBuilder builder = Marker.builder();
    if (sizeColumn != null) {
        builder.size(sizeColumn);
    }
    if (opacity != null) {
        builder.opacity(opacity);
    }
    if (color != null) {
        builder.color(color);
    }
    if (sizeMode != null) {
        builder.sizeMode(sizeMode);
    }
    marker = builder.build();
    ScatterTrace trace = ScatterTrace.builder(xColumn, yColumn).marker(marker).build();
    return new Figure(layout, trace);
}
Also used : Layout(tech.tablesaw.plotly.components.Layout) MarkerBuilder(tech.tablesaw.plotly.components.Marker.MarkerBuilder) Marker(tech.tablesaw.plotly.components.Marker) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Example 5 with Marker

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

the class BubbleExample method main.

public static void main(String[] args) throws IOException {
    Table marketShare = Table.read().csv("../data/market_share.csv");
    Table sub = marketShare.where(Selection.withRange(0, 4));
    NumericColumn<?> x = sub.nCol("Products");
    NumericColumn<?> y = sub.nCol("Sales");
    NumericColumn<?> data = sub.nCol("Market_Share");
    Layout layout = Layout.builder().title("Market Share").build();
    Marker marker = Marker.builder().size(data).sizeMode(Marker.SizeMode.AREA).build();
    ScatterTrace trace = ScatterTrace.builder(x, y).marker(marker).build();
    Plot.show(new Figure(layout, trace));
}
Also used : Table(tech.tablesaw.api.Table) Layout(tech.tablesaw.plotly.components.Layout) Marker(tech.tablesaw.plotly.components.Marker) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Aggregations

Marker (tech.tablesaw.plotly.components.Marker)5 Figure (tech.tablesaw.plotly.components.Figure)4 Layout (tech.tablesaw.plotly.components.Layout)4 Table (tech.tablesaw.api.Table)3 ScatterTrace (tech.tablesaw.plotly.traces.ScatterTrace)3 TableSliceGroup (tech.tablesaw.table.TableSliceGroup)2 Test (org.junit.jupiter.api.Test)1 MarkerBuilder (tech.tablesaw.plotly.components.Marker.MarkerBuilder)1 Scatter3DTrace (tech.tablesaw.plotly.traces.Scatter3DTrace)1