本文整理汇总了Java中org.jfree.chart.plot.XYPlot.setDataset方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.setDataset方法的具体用法?Java XYPlot.setDataset怎么用?Java XYPlot.setDataset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.XYPlot
的用法示例。
在下文中一共展示了XYPlot.setDataset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: linePlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public JFreeChart linePlot(String xLabel, String yLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createXYLineChart(
chartTitle, // chart title
xLabel, // x axis label
yLabel, // y axis label
dataset.get(0), // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = result.getXYPlot();
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
//plot.setRenderer(i, new XYLineAndShapeRenderer(false, true));
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:26,代码来源:Chart.java
示例2: scatterGridPlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public JFreeChart scatterGridPlot(String xLabel, String yLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createScatterPlot(chartTitle
, xLabel
, yLabel
, dataset.get(0));
XYPlot plot = result.getXYPlot();
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:20,代码来源:Chart.java
示例3: plotTradeBubblesOnChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
switch(j)
{
case 0:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
break;
case 1:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
break;
case 2:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
break;
case 3:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
break;
}
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++)
{
series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
}
*/
XYDataset dataSet = new TimeSeriesCollection(series);
plot.setDataset(k, dataSet);
XYItemRenderer ir = new XYShapeRenderer();
//ir.s
plot.setRenderer(k, ir);
}
示例4: testReplaceDataset
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Replaces the dataset and checks that it has changed as expected.
*/
public void testReplaceDataset() {
// create a dataset...
XYSeries series1 = new XYSeries("Series 1");
series1.add(10.0, 10.0);
series1.add(20.0, 20.0);
series1.add(30.0, 30.0);
XYDataset dataset = new XYSeriesCollection(series1);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
XYPlot plot = (XYPlot) this.chart.getPlot();
plot.setDataset(dataset);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around 10: "
+ range.getLowerBound(), range.getLowerBound() <= 10);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例5: testReplaceDataset
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Replaces the dataset and checks that it has changed as expected.
*/
public void testReplaceDataset() {
// create a dataset...
XYSeries series1 = new XYSeries("Series 1");
series1.add(10.0, 10.0);
series1.add(20.0, 20.0);
series1.add(30.0, 30.0);
XYDataset dataset = new XYSeriesCollection(series1);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
XYPlot plot = (XYPlot) this.chart.getPlot();
plot.setDataset(dataset);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around 10: "
+ range.getLowerBound(), range.getLowerBound() <= 10);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例6: testGetRendererForDataset
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Some checks for the getRendererForDataset() method.
*/
public void testGetRendererForDataset() {
XYDataset d0 = new XYSeriesCollection();
XYDataset d1 = new XYSeriesCollection();
XYDataset d2 = new XYSeriesCollection();
XYDataset d3 = new XYSeriesCollection(); // not used by plot
XYItemRenderer r0 = new XYLineAndShapeRenderer();
XYItemRenderer r2 = new XYLineAndShapeRenderer();
XYPlot plot = new XYPlot();
plot.setDataset(0, d0);
plot.setDataset(1, d1);
plot.setDataset(2, d2);
plot.setRenderer(0, r0);
// no renderer 1
plot.setRenderer(2, r2);
assertEquals(r0, plot.getRendererForDataset(d0));
assertEquals(r0, plot.getRendererForDataset(d1));
assertEquals(r2, plot.getRendererForDataset(d2));
assertEquals(null, plot.getRendererForDataset(d3));
assertEquals(null, plot.getRendererForDataset(null));
}
示例7: scatterPlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public JFreeChart scatterPlot(String xAxisLabel,String yAxisLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createScatterPlot(chartTitle
, xAxisLabel
, yAxisLabel
, dataset.get(0));
XYPlot plot = result.getXYPlot();
switch(seriesTypes.get(0)){
case DOTS:
plot.setRenderer(0, new XYLineAndShapeRenderer(false, true));
break;
case LINES:
plot.setRenderer(0, new XYLineAndShapeRenderer(true, true));
break;
}
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
switch(seriesTypes.get(i)){
case DOTS:
plot.setRenderer(i, new XYLineAndShapeRenderer(false, true));
break;
case LINES:
plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
break;
}
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:35,代码来源:Chart.java
示例8: pushDataAndRendererIntoPlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void pushDataAndRendererIntoPlot(XYPlot plot, int rangeAxisIdx, XYItemRenderer renderer, XYDataset dataset)
throws ChartPlottimeException {
if (dataset != null && renderer != null) {
int datasetIdx = plot.getDatasetCount();
if (datasetIdx > 0 && plot.getDataset(datasetIdx - 1) == null) {
datasetIdx -= 1;
}
// push dataset and renderer into plot
try {
plot.setDataset(datasetIdx, dataset); // if Eclipse states that
// dataset might not be
// initialized, you did
// not consider all
// possibilities in the
// condition block above
} catch (RuntimeException e) {
// probably this is because the domain axis contains values less
// then zero and the scaling is logarithmic.
// The shitty JFreeChart implementation does not throw a proper
// exception stating what happened,
// but just a RuntimeException with a string, so this is our
// best guess:
if (isProbablyZeroValuesOnLogScaleException(e)) {
throw new ChartPlottimeException("gui.plotter.error.log_axis_contains_zero", "domain axis");
} else {
throw e;
}
}
plot.mapDatasetToRangeAxis(datasetIdx, rangeAxisIdx);
plot.setRenderer(datasetIdx, renderer);
} else {
ChartPlottimeException chartPlottimeException = new ChartPlottimeException(new PlotConfigurationError(
"generic_plotter_error"));
throw chartPlottimeException;
}
}
示例9: plotIndicatorOnChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void plotIndicatorOnChart(Double[] toPlot, String p, int k)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
plot.setDataset(k, createIndicatorPlot(p,toPlot));
XYItemRenderer ir = new XYLineAndShapeRenderer(true,false);
plot.setRenderer(k, ir);
}
示例10: addCashFlowAxis
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Adds the cash flow axis to the plot.
* @param plot the plot
* @param dataset the cash flow dataset
*/
private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) {
final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio");
cashAxis.setAutoRangeIncludesZero(false);
plot.setRangeAxis(1, cashAxis);
plot.setDataset(1, dataset);
plot.mapDatasetToRangeAxis(1, 1);
final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer();
cashFlowRenderer.setSeriesPaint(0, Color.blue);
plot.setRenderer(1, cashFlowRenderer);
}
示例11: addSerie
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public void addSerie(int indexSerie, Color color, XYSeries localXYSeries){
XYPlot plot=null;
XYSeriesCollection localXYSeriesCollection = new XYSeriesCollection();
localXYSeriesCollection.addSeries(localXYSeries); //Se aniade la serie
Ellipse2D.Double localDouble = new Ellipse2D.Double(-4.0D, -4.0D, 8.0D, 8.0D); //Forma de la anotacion del punto x,y
XYLineAndShapeRenderer localXYLineAndShapeRenderer = new XYLineAndShapeRenderer();
localXYLineAndShapeRenderer.setSeriesLinesVisible(indexSerie,true); //provoca que se pinten lineas rectas que unen los puntos x,y que conforman la serie
localXYLineAndShapeRenderer.setSeriesShapesVisible(indexSerie,false); //provoca que se pinte la forma asociada al punto x,y
plot.setDataset(indexSerie, localXYSeriesCollection); //Se aniade la serie al plot
plot.setRenderer(indexSerie, localXYLineAndShapeRenderer);
localXYLineAndShapeRenderer.setSeriesShape(indexSerie, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));
// localXYLineAndShapeRenderer.setSeriesShape(indexSerie, localDouble);
localXYLineAndShapeRenderer.setSeriesPaint(indexSerie, color);
//localXYLineAndShapeRenderer.setSeriesFillPaint(indexSerie, Color.yellow);
//localXYLineAndShapeRenderer.setSeriesOutlinePaint(indexSerie, Color.gray);
localXYLineAndShapeRenderer.setUseFillPaint(false);//true
localXYLineAndShapeRenderer.setUseOutlinePaint(false);//true
localXYLineAndShapeRenderer.setDrawOutlines(false);
localXYLineAndShapeRenderer.setDrawSeriesLineAsPath(true);
}
示例12: testGetLegendItems
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Some checks for the getLegendItems() method.
*/
public void testGetLegendItems() {
// check the case where there is a secondary dataset that doesn't
// have a renderer (i.e. falls back to renderer 0)
XYDataset d0 = createDataset1();
XYDataset d1 = createDataset2();
XYItemRenderer r0 = new XYLineAndShapeRenderer();
XYPlot plot = new XYPlot();
plot.setDataset(0, d0);
plot.setDataset(1, d1);
plot.setRenderer(0, r0);
LegendItemCollection items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
}
示例13: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private JFreeChart createChart() {
final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
final ClusteredXYBarRenderer barRenderer = new ClusteredXYBarRenderer();
final GradientPaint black = new GradientPaint(0.0f, 0.0f, Color.black, 0.0f, 0.0f, Color.black);
final TimeSeries seriests = new TimeSeries("Series");
final TimeSeries seasonalts = new TimeSeries("Seasonal");
final TimeSeries trendts = new TimeSeries("Trend");
final TimeSeries remainderts = new TimeSeries("Remainder");
final TimeSeries[] tsArray = new TimeSeries[]{seriests, seasonalts, trendts};
final String[] labels = new String[]{"Series", "Seasonal", "Trend"};
for (int i = 0; i < series.length; i++) {
final Date d = new Date((long) times[i]);
RegularTimePeriod rtp = RegularTimePeriod.createInstance(this.timePeriod, d, TimeZone.getDefault());
seriests.addOrUpdate(rtp, series[i]);
seasonalts.addOrUpdate(rtp, seasonal[i]);
trendts.addOrUpdate(rtp, trend[i]);
remainderts.addOrUpdate(rtp, remainder[i]);
}
plot.setGap(10.0);
renderer.setSeriesPaint(0, black);
barRenderer.setSeriesPaint(0, black);
plot.setOrientation(PlotOrientation.VERTICAL);
for (int i = 0; i < tsArray.length; i++) {
final XYDataset ts = new TimeSeriesCollection(tsArray[i]);
final XYPlot p = new XYPlot(ts, new DateAxis(labels[i]), new NumberAxis(labels[i]), renderer);
plot.add(p);
}
final XYDataset rts = new TimeSeriesCollection(remainderts);
final XYDataset sts = new TimeSeriesCollection(seriests);
final XYDataset tts = new TimeSeriesCollection(trendts);
final XYPlot rplot = new XYPlot(rts, new DateAxis(), new NumberAxis("Remainder"), barRenderer);
final XYPlot seriesAndTrend = new XYPlot(sts, new DateAxis(), new NumberAxis("S & T"), renderer);
seriesAndTrend.setDataset(1, tts);
seriesAndTrend.setRenderer(1, renderer);
plot.add(rplot);
plot.add(seriesAndTrend);
return new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}
示例14: main
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public static void main(String[] args) {
/**
* Getting time series
*/
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
/**
* Creating the OHLC dataset
*/
OHLCDataset ohlcDataset = createOHLCDataset(series);
/**
* Creating the additional dataset
*/
TimeSeriesCollection xyDataset = createAdditionalDataset(series);
/**
* Creating the chart
*/
JFreeChart chart = ChartFactory.createCandlestickChart(
"Bitstamp BTC price",
"Time",
"USD",
ohlcDataset,
true);
// Candlestick rendering
CandlestickRenderer renderer = new CandlestickRenderer();
renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
XYPlot plot = chart.getXYPlot();
plot.setRenderer(renderer);
// Additional dataset
int index = 1;
plot.setDataset(index, xyDataset);
plot.mapDatasetToRangeAxis(index, 0);
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
renderer2.setSeriesPaint(index, Color.blue);
plot.setRenderer(index, renderer2);
// Misc
plot.setRangeGridlinePaint(Color.lightGray);
plot.setBackgroundPaint(Color.white);
NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
numberAxis.setAutoRangeIncludesZero(false);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
/**
* Displaying the chart
*/
displayChart(chart);
}
示例15: GeneratePlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public void GeneratePlot(String pngfile) throws IOException {
String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile) + "_ModelPoints.txt";
FileWriter writer = new FileWriter(modelfile);
double[] IDObs = new double[IDEmpiricalDist.getN()];
double[] DecoyObs = new double[DecoyEmpiricalDist.getN()];
for (int i = 0; i < IDEmpiricalDist.getN(); i++) {
IDObs[i] = IDEmpiricalDist.getObs(i);
}
for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) {
DecoyObs[i] = DecoyEmpiricalDist.getObs(i);
}
XYSeries model1 = new XYSeries("Incorrect matches");
XYSeries model2 = new XYSeries("Correct matches");
XYSeries model3 = new XYSeries("All target hits");
writer.write("UScore\tModel\tCorrect\tDecoy\n");
for (int i = 0; i < NoBinPoints; i++) {
model1.add(model_kde_x[i], decoy_kde_y[i]);
model2.add(model_kde_x[i], correct_kde_y[i]);
model3.add(model_kde_x[i], model_kde_y[i]);
writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i] + "\n");
}
writer.close();
MixtureModelProb = new Float[NoBinPoints + 1][3];
float positiveaccu = 0f;
float negativeaccu = 0f;
MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
MixtureModelProb[0][1] = 1f;
MixtureModelProb[0][2] = 1f;
for (int i = 1; i < NoBinPoints + 1; i++) {
double positiveNumber = correct_kde_y[NoBinPoints - i];
double negativeNumber = decoy_kde_y[NoBinPoints - i];
MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i];
positiveaccu += positiveNumber;
negativeaccu += negativeNumber;
MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber));
MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu));
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(model1);
dataset.addSeries(model2);
dataset.addSeries(model3);
HistogramDataset histogramDataset = new HistogramDataset();
histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
histogramDataset.addSeries("ID hits", IDObs, 100);
histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
//histogramDataset.addSeries("Model hits", ModelObs, 100);
JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits", histogramDataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = chart.getXYPlot();
NumberAxis domain = (NumberAxis) plot.getDomainAxis();
domain.setRange(min, max);
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setForegroundAlpha(0.8f);
chart.setBackgroundPaint(Color.white);
XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
plot.setDataset(1, dataset);
plot.setRenderer(1, render);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
try {
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
} catch (IOException e) {
}
}