本文整理汇总了Java中org.knowm.xchart.XYChart类的典型用法代码示例。如果您正苦于以下问题:Java XYChart类的具体用法?Java XYChart怎么用?Java XYChart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XYChart类属于org.knowm.xchart包,在下文中一共展示了XYChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例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: saveChart
import org.knowm.xchart.XYChart; //导入依赖的package包/类
private void saveChart(XYChart chart, String filename) {
try {
String base = "src/test/charts";
String fullPath = String.format("%s/%s", base, filename);
File f = new File(fullPath);
f.getParentFile().mkdirs();
BitmapEncoder.saveBitmapWithDPI(chart, fullPath, BitmapEncoder.BitmapFormat.PNG, 300);
}
catch (IOException e) {
e.printStackTrace();
}
}
示例11: 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()));
}
示例12: 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()));
}
}
示例13: buildCommonChart
import org.knowm.xchart.XYChart; //导入依赖的package包/类
private XYChart buildCommonChart() {
// Create Chart
XYChart chart = new XYChartBuilder()
.width(outputWidth)
.height(outputHeight)
.title(chartProperties.getTitle())
.xAxisTitle(null)
.yAxisTitle(chartProperties.getyTitle())
.build();
chart.getStyler().setPlotBackgroundColor(ChartColor.getAWTColor(ChartColor.WHITE));
chart.getStyler().setChartBackgroundColor(Color.WHITE);
chart.getStyler().setChartTitleBoxBackgroundColor(new Color(0, 222, 0));
chart.getStyler().setPlotGridLinesVisible(plotGridLinesVisible);
chart.getStyler().setYAxisTickMarkSpacingHint(15);
chart.getStyler().setXAxisTickMarkSpacingHint(10);
chart.getStyler().setXAxisMax(100.0);
chart.getStyler().setXAxisLabelRotation(45);
chart.getStyler().setAxisTickMarkLength(15);
chart.getStyler().setPlotMargin(0);
chart.getStyler().setPlotContentSize(.99);
chart.getStyler().setChartTitleFont(new Font("Verdana", Font.BOLD, 14));
chart.getStyler().setLegendFont(new Font("Verdana", Font.PLAIN, 12));
chart.getStyler().setAxisTitleFont(new Font("Verdana", Font.PLAIN, 12));
chart.getStyler().setAxisTickLabelsFont(new Font("Verdana", Font.PLAIN, 10));
return chart;
}
示例14: 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);
}
}
示例15: 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);
}