本文整理汇总了Java中org.knowm.xchart.XYChart.addSeries方法的典型用法代码示例。如果您正苦于以下问题:Java XYChart.addSeries方法的具体用法?Java XYChart.addSeries怎么用?Java XYChart.addSeries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.knowm.xchart.XYChart
的用法示例。
在下文中一共展示了XYChart.addSeries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public static void show(String chartTitle, NumericColumn xColumn, NumericColumn yColumn, ViewGroup 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 (TemporaryView view : group) {
double[] xData = view.numericColumn(xColumn.name()).toDoubleArray();
double[] yData = view.numericColumn(yColumn.name()).toDoubleArray();
chart.addSeries(view.name(), Arrays.copyOf(xData, xData.length), Arrays.copyOf(yData, yData.length));
}
new SwingWrapper<>(chart).displayChart(WINDOW_TITLE);
}
示例2: plot99
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
private void plot99(List<Double> xData, List<Double> yData) throws IOException {
XYChart chart = buildCommonChart();
/*
* This shows only the > 90 percentile, so set te minimum
* accordingly.
*/
chart.getStyler().setXAxisMin(99.0);
// Series
XYSeries series = chart.addSeries(chartProperties.getSeriesName(), xData, yData);
series.setLineColor(XChartSeriesColors.BLUE);
series.setMarkerColor(Color.LIGHT_GRAY);
series.setMarker(SeriesMarkers.NONE);
series.setLineStyle(SeriesLines.SOLID);
BitmapEncoder.saveBitmap(chart, baseName + "_99.png", BitmapEncoder.BitmapFormat.PNG);
}
示例3: plot90
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
private void plot90(List<Double> xData, List<Double> yData) throws IOException {
XYChart chart = buildCommonChart();
/*
* This shows only the > 90 percentile, so set te minimum
* accordingly.
*/
chart.getStyler().setXAxisMin(90.0);
// Series
XYSeries series = chart.addSeries(chartProperties.getSeriesName(), xData, yData);
series.setLineColor(XChartSeriesColors.BLUE);
series.setMarkerColor(Color.LIGHT_GRAY);
series.setMarker(SeriesMarkers.NONE);
series.setLineStyle(SeriesLines.SOLID);
BitmapEncoder.saveBitmap(chart, baseName + "_90.png", BitmapEncoder.BitmapFormat.PNG);
}
示例4: plotAll
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
private void plotAll(List<Double> xData, List<Double> yData) throws IOException {
// Create Chart
XYChart chart = buildCommonChart();
/*
* This shows almost everything so set te minimum
* accordingly.
*/
chart.getStyler().setXAxisMin(5.0);
// Series
XYSeries series = chart.addSeries(chartProperties.getSeriesName(), xData, yData);
series.setLineColor(XChartSeriesColors.BLUE);
series.setMarkerColor(Color.LIGHT_GRAY);
series.setMarker(SeriesMarkers.NONE);
series.setLineStyle(SeriesLines.SOLID);
BitmapEncoder.saveBitmap(chart, baseName + "_all.png", BitmapEncoder.BitmapFormat.PNG);
}
示例5: plot
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
/**
* Plot a time series, connecting the observation times to the measurements.
*
* @param timeSeries the series to plot.
* @param title the title of the plot.
* @param seriesName the name of the series to display.
*/
public static void plot(final TimeSeries timeSeries, final String title, final String seriesName) {
Thread plotThread = new Thread(() -> {
final List<Date> xAxis = new ArrayList<>(timeSeries.observationTimes().size());
for (OffsetDateTime dateTime : timeSeries.observationTimes()) {
xAxis.add(Date.from(dateTime.toInstant()));
}
List<Double> seriesList = Doubles.asList(round(timeSeries.asArray(), 2));
final XYChart chart = new XYChartBuilder().theme(Styler.ChartTheme.GGPlot2)
.height(600)
.width(800)
.title(title)
.build();
XYSeries residualSeries = chart.addSeries(seriesName, xAxis, seriesList);
residualSeries.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
residualSeries.setMarker(new Circle()).setMarkerColor(Color.RED);
JPanel panel = new XChartPanel<>(chart);
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setVisible(true);
});
plotThread.start();
}
示例6: show
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public static void show(String chartTitle, NumericColumn xColumn, NumericColumn yColumn, ViewGroup 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 (TemporaryView view : group) {
double[] xData = view.numericColumn(xColumn.name()).toDoubleArray();
double[] yData = view.numericColumn(yColumn.name()).toDoubleArray();
chart.addSeries(view.name(), Arrays.copyOf(xData, xData.length), Arrays.copyOf(yData, yData.length));
}
new SwingWrapper<>(chart).displayChart(WINDOW_TITLE);
}
示例7: main
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public static void main(String[] args) {
XYChart chart = new XYChartBuilder().width(800).height(600).build();
// Customize Chart
chart.getStyler().setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
chart.getStyler().setChartTitleVisible(false);
chart.getStyler().setLegendPosition(Styler.LegendPosition.InsideSW);
chart.getStyler().setXAxisMax(5.0);
chart.getStyler().setXAxisMin(-5.0);
chart.getStyler().setYAxisMax(5.0);
chart.getStyler().setYAxisMin(-5.0);
chart.getStyler().setMarkerSize(2);
// Series
double[] xData = normal(0, 1, 1000);
double[] yData = normal(0, 1, 1000);
chart.addSeries("Gaussian Blob", xData, yData);
new SwingWrapper<>(chart).displayChart();
}
示例8: addIndicatorChart
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public void addIndicatorChart(String indicator) {
XYChart indicatorChart = new XYChartBuilder().xAxisTitle("n").yAxisTitle(indicator).build();
indicatorChart.getStyler().setDefaultSeriesRenderStyle(XYSeriesRenderStyle.Scatter).setMarkerSize(5);
List<Integer> indicatorIterations = new ArrayList<Integer>();
indicatorIterations.add(0);
List<Double> indicatorValues = new ArrayList<Double>();
indicatorValues.add(0.0);
XYSeries indicatorSeries = indicatorChart.addSeries(this.name, indicatorIterations, indicatorValues);
indicatorSeries.setMarkerColor(Color.blue);
this.iterations.put(indicator, indicatorIterations);
this.indicatorValues.put(indicator, indicatorValues);
this.charts.put(indicator, indicatorChart);
}
示例9: main
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public static void main(String[] args) {
int row=0;
CSVReader fileReader = new CSVReader();
try {
fileReader.read(plotChanelArray);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int numCharts = 4;
List<XYChart> charts = new ArrayList<XYChart>();
double[] array = new double[22000];
for (int i=0;i<21000;i++){
array[i]=plotChanelArray[i][0];
}
for (int i = 0; i < numCharts; i++) {
XYChart chart = new XYChartBuilder().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build();
//chart.getStyler().setYAxisMin((double) -10);
// chart.getStyler().setYAxisMax((double) 10);
//XYSeries series = chart.addSeries("" + i, null, getRandomWalk(200));
XYSeries series = chart.addSeries("" + i, null, array);
series.setMarker(SeriesMarkers.NONE);
charts.add(chart);
}
new SwingWrapper<XYChart>(charts).displayChartMatrix();
//new ZoomManager(charts);
final StackPane pane = new StackPane();
pane.getChildren().add((Node) charts);
final Scene scene = new Scene(pane, 500, 400);
}
示例10: AveragePlannedFeaturesTest
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
private void AveragePlannedFeaturesTest()
{
NextReleaseProblem base = random.all(7, 20, 5, 4, 40.0);
SolverNRP solver = new SolverNRP(SolverNRP.AlgorithmType.NSGAII);
List<Integer> iterations = new ArrayList<>();
List<Integer> nbPlannedFeatures = new ArrayList<>();
int totalPlannedFeatures = 0;
int nbIterations = 20;
for (int i = 0; i < nbIterations; ++i) {
NextReleaseProblem problem = new NextReleaseProblem(base);
PlanningSolution solution = execute(problem, solver);
iterations.add(i+1);
nbPlannedFeatures.add(solution.getPlannedFeatures().size());
totalPlannedFeatures += solution.getPlannedFeatures().size();
}
String title = String.format("Algorithm: %s. Test set: %s", solver.getAlgorithmType().getName(), "Random");
XYChart chart = new XYChartBuilder().width(1024).height(512).title(title)
.xAxisTitle("Iteration").yAxisTitle("Number of features planned").build();
chart.addSeries("Number of planned features", iterations, nbPlannedFeatures);
List<Double> average = new ArrayList<>();
for (int i = 0; i < nbIterations; ++i)
average.add((double) totalPlannedFeatures/nbIterations);
chart.addSeries("Average planned features", iterations, average);
chart.getStyler().setXAxisMin(0.0).setYAxisMin(0.0)
.setXAxisMax((double) iterations.size()).setYAxisMax((double) base.getFeatures().size());
saveChart(chart, String.format("AveragePlannedFeatures_%s_%s", algorithmName(solver), timestamp()));
}
示例11: populationSizeTest
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public void populationSizeTest() {
for (int k = 0; k < 5; ++k) {
NextReleaseProblem base = random.all(7, 20, 5, 4, 40.0);
SolverNRP solver = new SolverNRP(SolverNRP.AlgorithmType.NSGAII);
List<Integer> populationSize = new ArrayList<>();
List<Double> executionTime = new ArrayList<>();
List<Integer> plannedFeatures = new ArrayList<>();
for (int i = 0; i < 15; ++i) {
AlgorithmParameters params = new AlgorithmParameters(SolverNRP.AlgorithmType.NSGAII);
params.setPopulationSize(params.getPopulationSize() + ++i * 10);
NextReleaseProblem problem = new NextReleaseProblem(base);
problem.setAlgorithmParameters(params);
long start = System.currentTimeMillis();
PlanningSolution solution = execute(problem, solver);
long elapsed = System.currentTimeMillis() - start;
populationSize.add(params.getPopulationSize());
executionTime.add(elapsed / 1000.0);
plannedFeatures.add(solution.size());
}
XYChart chart = new XYChartBuilder().width(1024).height(512).title("Population/Performance chart")
.xAxisTitle("Population size").build();
chart.addSeries("Execution time (seconds)", populationSize, executionTime);
chart.addSeries("Number of planned features", populationSize, plannedFeatures);
saveChart(chart, String.format("PopulationSizeTest_%s_%s", algorithmName(solver), timestamp()));
}
}
示例12: afterReportInit
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
@Override
public void afterReportInit() throws JRScriptletException
{
try
{
XYChart xyChart = new XYChartBuilder()
.width(515)
.height(400)
.title("Fruits Order")
.xAxisTitle("Day of Week")
.yAxisTitle("Quantity (t)")
.build();
xyChart.addSeries("Apples", new double[] { 1, 3, 5}, new double[] {4, 10, 7});
xyChart.addSeries("Bananas", new double[] { 1, 2, 3, 4, 5}, new double[] {6, 8, 4, 4, 6});
xyChart.addSeries("Cherries", new double[] { 1, 3, 4, 5}, new double[] {2, 6, 1, 9});
XYStyler styler = xyChart.getStyler();
styler.setLegendPosition(Styler.LegendPosition.InsideNW);
styler.setAxisTitlesVisible(true);
styler.setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Area);
styler.setChartBackgroundColor(Color.WHITE);
BufferedImage bufferedImage = BitmapEncoder.getBufferedImage(xyChart);
super.setVariableValue("ChartImage", bufferedImage);
}
catch(Exception e)
{
throw new JRScriptletException(e);
}
}
示例13: show
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
public static void show(String chartTitle, double[] xData, NumericColumn yColumn, int width, int height) {
double[] yData = yColumn.toDoubleArray();
// 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);
}
示例14: copy
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
protected void copy(JRPrintImage image)
{
dataset.finishDataset();
JRComponentElement element = fillContext.getComponentElement();
XYChart xyChart = new XYChartBuilder()
.width(element.getWidth())
.height(element.getHeight())
.title(chartTitle == null ? "" : chartTitle)
.xAxisTitle(xAxisTitle == null ? "" : xAxisTitle)
.yAxisTitle(yAxisTitle == null ? "" : yAxisTitle)
.build();
XYStyler styler = xyChart.getStyler();
styler.setLegendPosition(Styler.LegendPosition.InsideNE);
styler.setAxisTitlesVisible(true);
styler.setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Area);
styler.setChartBackgroundColor(element.getBackcolor() == null ? Color.WHITE : element.getBackcolor());
List<Comparable<?>> xySeriesNames = dataset.getXYSeriesNames();
Map<Comparable<?>, XYSeriesData> xySeriesMap = dataset.getXYSeriesMap();
if(xySeriesMap != null && !xySeriesMap.isEmpty())
{
int i = 0;
for(Comparable<?> name : xySeriesNames)
{
XYSeriesData data = xySeriesMap.get(name);
org.knowm.xchart.XYSeries series = xyChart.addSeries(name.toString(), data.getXData(), data.getYData());
Color color = data.getColor();
if(color != null)
{
series.setLineColor(color);
styler.getSeriesColors()[i] = color;
//series.setFillColor(color);
}
i++;
}
}
try
{
BufferedImage img = BitmapEncoder.getBufferedImage(xyChart);
Renderable renderable = RendererUtil
.getInstance(fillContext.getFiller().getJasperReportsContext())
.getRenderable(img, ImageTypeEnum.PNG, OnErrorTypeEnum.ERROR);
image.setRenderer(renderable);
}
catch(Exception e)
{
throw new JRRuntimeException(e);
}
}
示例15: plotAcf
import org.knowm.xchart.XYChart; //导入方法依赖的package包/类
/**
* Plot the sample autocorrelations of the given time series up to the given lag.
*
* @param timeSeries the series to plot.
* @param k the maximum lag to include in the acf plot.
*/
public static void plotAcf(TimeSeries timeSeries, final int k) {
final double[] acf = timeSeries.autoCorrelationUpToLag(k);
final double[] lags = new double[k + 1];
for (int i = 1; i < lags.length; i++) {
lags[i] = i;
}
final double upper = (-1 / timeSeries.size()) + (2 / Math.sqrt(timeSeries.size()));
final double lower = (-1 / timeSeries.size()) - (2 / Math.sqrt(timeSeries.size()));
final double[] upperLine = new double[lags.length];
final double[] lowerLine = new double[lags.length];
for (int i = 0; i < lags.length; i++) {
upperLine[i] = upper;
}
for (int i = 0; i < lags.length; i++) {
lowerLine[i] = lower;
}
Thread plotThread = new Thread(() -> {
XYChart chart = new XYChartBuilder().theme(Styler.ChartTheme.GGPlot2)
.height(800)
.width(1200)
.title("Autocorrelations By Lag")
.build();
XYSeries series = chart.addSeries("Autocorrelation", lags, acf);
XYSeries series2 = chart.addSeries("Upper Bound", lags, upperLine);
XYSeries series3 = chart.addSeries("Lower Bound", lags, lowerLine);
chart.getStyler()
.setChartFontColor(Color.BLACK)
.setSeriesColors(new Color[]{Color.BLACK, Color.BLUE, Color.BLUE});
series.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
series2.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Line)
.setMarker(SeriesMarkers.NONE)
.setLineStyle(SeriesLines.DASH_DASH);
series3.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Line)
.setMarker(SeriesMarkers.NONE)
.setLineStyle(SeriesLines.DASH_DASH);
JPanel panel = new XChartPanel<>(chart);
JFrame frame = new JFrame("Autocorrelation by Lag");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setVisible(true);
});
plotThread.start();
}