Search in sources :

Example 1 with HistogramTrace

use of tech.tablesaw.plotly.traces.HistogramTrace in project tablesaw by jtablesaw.

the class HistogramOverlayExample method main.

public static void main(String[] args) throws Exception {
    Table baseball = Table.read().csv("../data/baseball.csv");
    Layout layout = Layout.builder().title("Distribution of team batting averages").barMode(Layout.BarMode.OVERLAY).showLegend(true).build();
    TableSliceGroup groups = baseball.splitOn("league");
    Table t1 = groups.get(0).asTable();
    HistogramTrace trace1 = HistogramTrace.builder(t1.nCol("BA")).name("American Leage").opacity(.75).nBinsX(24).marker(Marker.builder().color("#FF4136").build()).build();
    Table t2 = groups.get(1).asTable();
    HistogramTrace trace2 = HistogramTrace.builder(t2.nCol("BA")).name("National League").opacity(.75).nBinsX(24).marker(Marker.builder().color("#7FDBFF").build()).build();
    Plot.show(new Figure(layout, trace1, trace2));
}
Also used : Table(tech.tablesaw.api.Table) HistogramTrace(tech.tablesaw.plotly.traces.HistogramTrace) Layout(tech.tablesaw.plotly.components.Layout) TableSliceGroup(tech.tablesaw.table.TableSliceGroup) Figure(tech.tablesaw.plotly.components.Figure)

Example 2 with HistogramTrace

use of tech.tablesaw.plotly.traces.HistogramTrace in project tablesaw by jtablesaw.

the class HistogramProbabilityExample method main.

public static void main(String[] args) throws Exception {
    Table baseball = Table.read().csv("../data/baseball.csv");
    Layout layout = Layout.builder().title("Probability Histogram of team batting averages").build();
    HistogramTrace trace = HistogramTrace.builder(baseball.nCol("BA")).histNorm(HistogramTrace.HistNorm.PROBABILITY).build();
    Plot.show(new Figure(layout, trace));
}
Also used : Table(tech.tablesaw.api.Table) HistogramTrace(tech.tablesaw.plotly.traces.HistogramTrace) Layout(tech.tablesaw.plotly.components.Layout) Figure(tech.tablesaw.plotly.components.Figure)

Example 3 with HistogramTrace

use of tech.tablesaw.plotly.traces.HistogramTrace in project tablesaw by jtablesaw.

the class HistogramTraceTest method testAsJavascript.

@Test
public void testAsJavascript() {
    HistogramTrace trace1 = HistogramTrace.builder(y1).build();
    System.out.println(trace1.asJavascript(1));
}
Also used : HistogramTrace(tech.tablesaw.plotly.traces.HistogramTrace) Test(org.junit.jupiter.api.Test)

Example 4 with HistogramTrace

use of tech.tablesaw.plotly.traces.HistogramTrace in project tablesaw by jtablesaw.

the class HistogramTraceTest method show.

@Test
public void show() {
    Layout layout = Layout.builder().barMode(Layout.BarMode.OVERLAY).build();
    HistogramTrace trace1 = HistogramTrace.builder(y1).opacity(.75).build();
    HistogramTrace trace2 = HistogramTrace.builder(y2).opacity(.75).build();
    Plot.show(new Figure(layout, trace1, trace2));
}
Also used : HistogramTrace(tech.tablesaw.plotly.traces.HistogramTrace) Layout(tech.tablesaw.plotly.components.Layout) Figure(tech.tablesaw.plotly.components.Figure) Test(org.junit.jupiter.api.Test)

Example 5 with HistogramTrace

use of tech.tablesaw.plotly.traces.HistogramTrace in project tablesaw by jtablesaw.

the class DistributionVisualizations method main.

public static void main(String[] args) throws Exception {
    Table property = Table.read().csv("../data/sacramento_real_estate_transactions.csv");
    IntColumn sqft = property.intColumn("sq__ft");
    IntColumn price = property.intColumn("price");
    sqft.set(sqft.isEqualTo(0), IntColumnType.missingValueIndicator());
    price.set(price.isEqualTo(0), IntColumnType.missingValueIndicator());
    Plot.show(Histogram.create("Distribution of prices", property.numberColumn("price")));
    Layout layout = Layout.builder().title("Distribution of property sizes").build();
    HistogramTrace trace = HistogramTrace.builder(property.numberColumn("sq__ft")).marker(Marker.builder().color("#B10DC9").opacity(.70).build()).build();
    Plot.show(new Figure(layout, trace));
    Plot.show(Histogram2D.create("Distribution of price and size", property, "price", "sq__ft"));
    Plot.show(BoxPlot.create("Prices by property type", property, "type", "price"));
}
Also used : Table(tech.tablesaw.api.Table) HistogramTrace(tech.tablesaw.plotly.traces.HistogramTrace) Layout(tech.tablesaw.plotly.components.Layout) IntColumn(tech.tablesaw.api.IntColumn) Figure(tech.tablesaw.plotly.components.Figure)

Aggregations

HistogramTrace (tech.tablesaw.plotly.traces.HistogramTrace)8 Figure (tech.tablesaw.plotly.components.Figure)7 Layout (tech.tablesaw.plotly.components.Layout)7 Table (tech.tablesaw.api.Table)6 Test (org.junit.jupiter.api.Test)2 TableSliceGroup (tech.tablesaw.table.TableSliceGroup)2 IntColumn (tech.tablesaw.api.IntColumn)1