Search in sources :

Example 1 with ScatterTrace

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

the class TimeSeriesPlot method create.

public static Figure create(String title, String xTitle, InstantColumn xCol, String yTitle, NumericColumn<?> yCol) {
    Layout layout = Layout.builder(title, xTitle, yTitle).build();
    ScatterTrace trace = ScatterTrace.builder(xCol, yCol).mode(ScatterTrace.Mode.LINE).build();
    return new Figure(layout, trace);
}
Also used : Layout(tech.tablesaw.plotly.components.Layout) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Example 2 with ScatterTrace

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

the class TimeSeriesPlot method create.

public static Figure create(String title, String xTitle, DateTimeColumn xCol, String yTitle, NumericColumn<?> yCol) {
    Layout layout = Layout.builder(title, xTitle, yTitle).build();
    ScatterTrace trace = ScatterTrace.builder(xCol, yCol).mode(ScatterTrace.Mode.LINE).build();
    return new Figure(layout, trace);
}
Also used : Layout(tech.tablesaw.plotly.components.Layout) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Example 3 with ScatterTrace

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

the class TimeSeriesPlot method createDateTimeSeries.

/**
 * Creates a time series where the x values are from a DateTimeColumn, rather than a DateColumn
 *
 * @param title The title of the plot
 * @param table The table containing the source data
 * @param dateTimeColumnName The name of a DateTimeColumn
 * @param numberColumnName The name of a NumberColumn
 * @return The figure to be displayed
 */
public static Figure createDateTimeSeries(String title, Table table, String dateTimeColumnName, String numberColumnName) {
    DateTimeColumn xCol = table.dateTimeColumn(dateTimeColumnName);
    NumericColumn<?> yCol = table.numberColumn(numberColumnName);
    Layout layout = Layout.builder(title, xCol.name(), yCol.name()).build();
    ScatterTrace trace = ScatterTrace.builder(xCol, yCol).mode(ScatterTrace.Mode.LINE).build();
    return new Figure(layout, trace);
}
Also used : Layout(tech.tablesaw.plotly.components.Layout) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) DateTimeColumn(tech.tablesaw.api.DateTimeColumn) Figure(tech.tablesaw.plotly.components.Figure)

Example 4 with ScatterTrace

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

the class TimeSeriesPlot method create.

public static Figure create(String title, String xTitle, DateColumn xCol, String yTitle, NumericColumn<?> yCol) {
    Layout layout = Layout.builder(title, xTitle, yTitle).build();
    ScatterTrace trace = ScatterTrace.builder(xCol, yCol).mode(ScatterTrace.Mode.LINE).build();
    return new Figure(layout, trace);
}
Also used : Layout(tech.tablesaw.plotly.components.Layout) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Example 5 with ScatterTrace

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

the class TukeyMeanDifferencePlot method create.

/**
 * Returns a figure containing a QQ Plot describing the differences between the distribution of
 * values in the columns of interest
 *
 * @param title A title for the plot
 * @param measure The measure being compared on the plot (e.g "inches" or "height in inches"
 * @param xData The data to plot on the x Axis
 * @param yData The data to plot on the y Axis
 * @return A quantile plot
 */
public static Figure create(String title, String measure, double[] xData, double[] yData) {
    Preconditions.checkArgument(xData.length != 0, "x Data array is empty");
    Preconditions.checkArgument(yData.length != 0, "x Data array is empty");
    if (xData.length != yData.length) {
        double[] interpolatedData;
        if (xData.length < yData.length) {
            interpolatedData = interpolate(yData, xData.length);
            yData = interpolatedData;
        } else {
            interpolatedData = interpolate(xData, yData.length);
            xData = interpolatedData;
        }
    }
    Arrays.sort(xData);
    Arrays.sort(yData);
    double[] averagePoints = new double[xData.length];
    double[] differencePoints = new double[xData.length];
    for (int i = 0; i < xData.length; i++) {
        averagePoints[i] = (xData[i] + yData[i]) / 2.0;
        differencePoints[i] = (xData[i] - yData[i]);
    }
    double xMin = StatUtils.min(xData);
    double xMax = StatUtils.max(xData);
    double[] zeroLineX = { xMin, xMax };
    double[] zeroLineY = { 0, 0 };
    // Draw the line indicating equal distributions (this is zero in this plot)
    ScatterTrace trace1 = ScatterTrace.builder(zeroLineX, zeroLineY).mode(ScatterTrace.Mode.LINE).name("y = x").build();
    // Draw the actual data points
    ScatterTrace trace2 = ScatterTrace.builder(averagePoints, differencePoints).name("mean x difference").build();
    Layout layout = Layout.builder().title(title).xAxis(Axis.builder().title("mean (" + measure + ")").build()).yAxis(Axis.builder().title("difference (" + measure + ")").build()).height(700).width(900).build();
    return new Figure(layout, trace1, trace2);
}
Also used : Layout(tech.tablesaw.plotly.components.Layout) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Figure(tech.tablesaw.plotly.components.Figure)

Aggregations

ScatterTrace (tech.tablesaw.plotly.traces.ScatterTrace)39 Figure (tech.tablesaw.plotly.components.Figure)36 Layout (tech.tablesaw.plotly.components.Layout)33 Table (tech.tablesaw.api.Table)9 Test (org.junit.jupiter.api.Test)8 File (java.io.File)5 Marker (tech.tablesaw.plotly.components.Marker)3 TableSliceGroup (tech.tablesaw.table.TableSliceGroup)3 DateTimeColumn (tech.tablesaw.api.DateTimeColumn)2 IntColumn (tech.tablesaw.api.IntColumn)2 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 DoubleColumn (tech.tablesaw.api.DoubleColumn)1 Axis (tech.tablesaw.plotly.components.Axis)1 FigureBuilder (tech.tablesaw.plotly.components.Figure.FigureBuilder)1 MarkerBuilder (tech.tablesaw.plotly.components.Marker.MarkerBuilder)1 TickSettings (tech.tablesaw.plotly.components.TickSettings)1 HoverBroadcastBody (tech.tablesaw.plotly.event.HoverBroadcastBody)1 HoverEventHandler (tech.tablesaw.plotly.event.HoverEventHandler)1