org.knowm.xchart.XYChart.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.knowm.xchart.XYChart.<init>()方法的一些代码示例,展示了XYChart.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XYChart.<init>()方法的具体详情如下:
包路径:org.knowm.xchart.XYChart
类名称:XYChart
方法名:<init>

XYChart.<init>介绍

[英]Constructor - the default Chart Theme will be used (XChartTheme)
[中]构造函数-将使用默认的图表主题(XChartTheme)

代码示例

代码示例来源:origin: knowm/XChart

/**
  * return fully built XYChart
  *
  * @return a XYChart
  */
 @Override
 public XYChart build() {

  return new XYChart(this);
 }
}

代码示例来源:origin: knowm/XChart

public static void main(String[] args) throws Exception {

  double[] xData = new double[] {0.0, 1.0, 2.0};
  double[] yData = new double[] {2.0, 1.0, 0.0};

  XYChart chart = new XYChart(500, 200);
  XYSeries xySeries = chart.addSeries("Sample Chart", xData, yData);
  xySeries.setEnabled(false);

  new SwingWrapper(chart).displayChart();
 }
}

代码示例来源:origin: knowm/XChart

private static XYChart createChart(String title, double[] yData) {
  XYChart chart = new XYChart(300, 200);
  chart.setTitle(title);
  chart.setXAxisTitle("X");
  chart.setXAxisTitle("Y");
  chart.addSeries("y(x)", null, yData);
  return chart;
 }
}

代码示例来源:origin: knowm/XChart

chart = new XYChart(width, height, chartTheme);
} else {
 chart = new XYChart(width, height);

代码示例来源:origin: org.knowm.xchart/xchart

/**
  * return fully built XYChart
  *
  * @return a XYChart
  */
 @Override
 public XYChart build() {

  return new XYChart(this);
 }
}

代码示例来源:origin: knowm/XChart

public static void main(String[] args) throws IOException {
 final XYChart chart = new XYChart(1920, 1080);
 XYStyler manager = chart.getStyler();
 manager.setLegendPosition(LegendPosition.InsideNW);

代码示例来源:origin: knowm/XChart

XYChart chart = new XYChart(WIDTH, HEIGHT);
XYChart chart = new XYChart(WIDTH, HEIGHT);

代码示例来源:origin: knowm/XChart

public static void main(String[] args) throws IOException {
 final XYChart chart = new XYChart(500, 580);
 final Styler styleManager = chart.getStyler();
 styleManager.setLegendPosition(LegendPosition.InsideNW);

代码示例来源:origin: knowm/XChart

public static void main(String[] args) throws Exception {

  double[] yData = new double[] {2.0, 1.0, 0.0};

  // Create Chart
  XYChart chart = new XYChart(500, 400);
  chart.setTitle("Sample Chart");
  chart.setXAxisTitle("X");
  chart.setXAxisTitle("Y");
  XYSeries series = chart.addSeries("y(x)", null, yData);
  series.setMarker(SeriesMarkers.CIRCLE);

  BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapFormat.PNG);
  BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapFormat.JPG);
  BitmapEncoder.saveJPGWithQuality(chart, "./Sample_Chart_With_Quality.jpg", 0.95f);
  BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapFormat.BMP);
  BitmapEncoder.saveBitmap(chart, "./Sample_Chart", BitmapFormat.GIF);

  BitmapEncoder.saveBitmapWithDPI(chart, "./Sample_Chart_300_DPI", BitmapFormat.PNG, 300);
  BitmapEncoder.saveBitmapWithDPI(chart, "./Sample_Chart_300_DPI", BitmapFormat.JPG, 300);
  BitmapEncoder.saveBitmapWithDPI(chart, "./Sample_Chart_300_DPI", BitmapFormat.GIF, 300);

  VectorGraphicsEncoder.saveVectorGraphic(chart, "./Sample_Chart", VectorGraphicsFormat.EPS);
  VectorGraphicsEncoder.saveVectorGraphic(chart, "./Sample_Chart", VectorGraphicsFormat.PDF);
  VectorGraphicsEncoder.saveVectorGraphic(chart, "./Sample_Chart", VectorGraphicsFormat.SVG);
 }
}

代码示例来源:origin: knowm/XChart

public static void main(String[] args) throws Exception {

  double[] xData = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
  double[] yData1 = new double[] {100, 100, 100, 50, 50, 50, 50};
  double[] errdata = new double[] {50, 20, 10, 50, 40, 20, 10};

  double[] yData2 = new double[] {50, 80, 90, 0, 10, 30, 40};
  double[] yData3 = new double[] {150, 120, 110, 100, 90, 70, 60};

  XYChart mychart = new XYChart(900, 700);
  mychart.getStyler().setYAxisMin(0.0);
  mychart.getStyler().setYAxisMax(150.0);
  mychart.getStyler().setErrorBarsColor(Color.black);
  XYSeries series1 = mychart.addSeries("Error bar test data", xData, yData1, errdata);
  XYSeries series2 = mychart.addSeries("Y+error", xData, yData2);
  XYSeries series3 = mychart.addSeries("Y-error", xData, yData3);
  series1.setLineStyle(SeriesLines.SOLID);
  series1.setMarker(SeriesMarkers.DIAMOND);
  series1.setMarkerColor(Color.MAGENTA);
  series2.setLineStyle(SeriesLines.DASH_DASH);
  series2.setMarker(SeriesMarkers.NONE);
  series2.setLineColor(XChartSeriesColors.RED);
  series3.setLineStyle(SeriesLines.DASH_DASH);
  series3.setMarker(SeriesMarkers.NONE);
  series3.setLineColor(XChartSeriesColors.RED);

  new SwingWrapper(mychart).displayChart();
 }
}

代码示例来源:origin: knowm/XChart

XYChart mychart = new XYChart(1200, 800);

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, NumberColumn xColumn, NumberColumn yColumn, TableSliceGroup group) {
  XYChart chart = new XYChart(DEFAULT_WIDTH, DEFAULT_HEIGHT);
  chart.setTitle(chartTitle);
  chart.setXAxisTitle(xColumn.name());
  chart.setYAxisTitle(yColumn.name());
  chart.getStyler().setTheme(new TablesawTheme());
  chart.getStyler().setMarkerSize(5);
  chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
  for (TableSlice view : group) {
    double[] xData = view.numberColumn(xColumn.name()).asDoubleArray();
    double[] yData = view.numberColumn(yColumn.name()).asDoubleArray();
    chart.addSeries(view.name(), Arrays.copyOf(xData, xData.length), Arrays.copyOf(yData, yData.length));
  }
  new SwingWrapper<>(chart).displayChart(WINDOW_TITLE);
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, NumberColumn xColumn, NumberColumn yColumn, TableSliceGroup group) {
  XYChart chart = new XYChart(DEFAULT_WIDTH, DEFAULT_HEIGHT);
  chart.setTitle(chartTitle);
  chart.setXAxisTitle(xColumn.name());
  chart.setYAxisTitle(yColumn.name());
  chart.getStyler().setTheme(new TablesawTheme());
  chart.getStyler().setMarkerSize(5);
  chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
  for (Table view : group.asTableList()) {
    double[] xData = view.numberColumn(xColumn.name()).asDoubleArray();
    double[] yData = view.numberColumn(yColumn.name()).asDoubleArray();
    chart.addSeries(view.name(), Arrays.copyOf(xData, xData.length), Arrays.copyOf(yData, yData.length));
  }
  new SwingWrapper<>(chart).displayChart(WINDOW_TITLE);
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, double[] xData, String xLabel, double[] yData, String yLabel, int
    width, int height) {
  // Create Chart
  XYChart chart = new XYChart(width, height);
  chart.setTitle(chartTitle);
  chart.setXAxisTitle(xLabel);
  chart.setYAxisTitle(yLabel);
  chart.getStyler().setTheme(new TablesawTheme());
  chart.getStyler().setMarkerSize(5);
  chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
  XYSeries series = chart.addSeries(SERIES, xData, yData);
  series.setMarker(SeriesMarkers.CIRCLE);
  new SwingWrapper<>(chart)
      .displayChart(WINDOW_TITLE);
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, String xTitle, double[] x, String yTitle, double[] y) {

    XYChart chart = new XYChart(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    chart.setTitle(chartTitle);
    chart.setXAxisTitle(xTitle);
    chart.setYAxisTitle(yTitle);
    chart.getStyler().setTheme(new TablesawTheme());
    chart.getStyler().setMarkerSize(4);
    chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);

    XYSeries series = chart.addSeries(chartTitle, x, y);
    series.setMarker(SeriesMarkers.CIRCLE);
    new SwingWrapper<>(chart)
        .displayChart(WINDOW_TITLE);

  }
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, double[] xData, NumberColumn yColumn, int width, int height) {
  double[] yData = yColumn.asDoubleArray();
  // Create Chart
  XYChart chart = new XYChart(width, height);
  chart.setTitle(chartTitle);
  chart.setYAxisTitle(yColumn.name());
  chart.getStyler().setTheme(new TablesawTheme());
  chart.getStyler().setMarkerSize(2);
  chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
  XYSeries series = chart.addSeries("Ranked: " + yColumn.name(), xData, yData);
  series.setMarker(SeriesMarkers.CIRCLE);
  new SwingWrapper<>(chart).displayChart(WINDOW_TITLE);
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, double[] xData, NumberColumn yColumn, int width, int height) {
  double[] yData = yColumn.asDoubleArray();
  // Create Chart
  XYChart chart = new XYChart(width, height);
  chart.setTitle(chartTitle);
  chart.setYAxisTitle(yColumn.name());
  chart.getStyler().setTheme(new TablesawTheme());
  chart.getStyler().setMarkerSize(2);
  chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
  XYSeries series = chart.addSeries("Ranked: " + yColumn.name(), xData, yData);
  series.setMarker(SeriesMarkers.CIRCLE);
  new SwingWrapper<>(chart)
      .displayChart(WINDOW_TITLE);
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle, double[] xData, NumberColumn yColumn, int width, int height) {
    double[] yData = yColumn.asDoubleArray();

    // Create Chart
    XYChart chart = new XYChart(width, height);
    chart.setTitle(chartTitle);
    chart.setYAxisTitle(yColumn.name());
    chart.getStyler().setTheme(new TablesawTheme());
    chart.getStyler().setMarkerSize(2);
    chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);

    XYSeries series = chart.addSeries("Ranked: " + yColumn.name(), xData, yData);
    series.setMarker(SeriesMarkers.CIRCLE);
    new SwingWrapper<>(chart).displayChart(XchartDefaults.WINDOW_TITLE);
  }
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

/**
   * Displays a line chart with the first numeric column used for the x axis, and the others as
   * series to plot against it
   */
  public static void show(String chartTitle, NumberColumn x, NumberColumn... ySeries) {

    XYChart chart = new XYChart(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    chart.setTitle(chartTitle);
    chart.setXAxisTitle(x.name());
    chart.getStyler().setTheme(new TablesawTheme());
    chart.getStyler().setMarkerSize(1);
    chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Line);

    for (NumberColumn y : ySeries) {
      chart.addSeries(y.name(), x.asDoubleArray(), y.asDoubleArray());
    }
    new SwingWrapper<>(chart)
        .displayChart(WINDOW_TITLE);
  }
}

代码示例来源:origin: tech.tablesaw/tablesaw-plot

public static void show(String chartTitle,
            NumberColumn xColumn,
            NumberColumn yColumn,
            int width,
            int height,
            int markerSize) {
  double[] xData = xColumn.asDoubleArray();
  double[] yData = yColumn.asDoubleArray();
  // Create Chart
  XYChart chart = new XYChart(width, height);
  chart.setTitle(chartTitle);
  chart.setXAxisTitle(xColumn.name());
  chart.setYAxisTitle(yColumn.name());
  chart.getStyler().setTheme(new TablesawTheme());
  chart.getStyler().setMarkerSize(markerSize);
  chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
  XYSeries series = chart.addSeries(yColumn.name() + " by " + xColumn.name(), xData, yData);
  series.setMarker(SeriesMarkers.CIRCLE);
  new SwingWrapper<>(chart).displayChart(WINDOW_TITLE);
}

相关文章