當前位置: 首頁>>代碼示例>>Java>>正文


Java ChartFactory.createScatterPlot方法代碼示例

本文整理匯總了Java中org.jfree.chart.ChartFactory.createScatterPlot方法的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory.createScatterPlot方法的具體用法?Java ChartFactory.createScatterPlot怎麽用?Java ChartFactory.createScatterPlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jfree.chart.ChartFactory的用法示例。


在下文中一共展示了ChartFactory.createScatterPlot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return the chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createScatterPlot(
        "Scatter Plot",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        false            // urls
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:ScatterPlotTests.java

示例2: testAxisMargins

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Tests the the lower and upper margin settings produce the expected results.
 */
public void testAxisMargins() {
    XYSeries series = new XYSeries("S1");
    series.add(100.0, 1.1);
    series.add(200.0, 2.2);
    XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setIntervalWidth(0.0);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Title", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false
    );
    ValueAxis domainAxis = chart.getXYPlot().getDomainAxis();
    Range r = domainAxis.getRange();
    assertTrue(NumberUtils.equal(110.0, r.getLength()));
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertTrue(NumberUtils.equal(120.0, r.getLength()));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:ValueAxisTests.java

示例3: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    XYDataset dataset = new XYSeriesCollection(series1);

    // create the chart...
    return ChartFactory.createScatterPlot(
        "Scatter Plot",  // chart title
        "Domain",
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        false            // urls
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:ScatterPlotTests.java

示例4: testXYAutoRange1

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Checks that the auto-range for the domain axis on an XYPlot is
 * working as expected.
 */
public void testXYAutoRange1() {
    XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 1.0);
    series.add(2.0, 2.0);
    series.add(3.0, 3.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Test", 
        "X",
        "Y",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(0.9, axis.getLowerBound(), EPSILON);    
    assertEquals(3.1, axis.getUpperBound(), EPSILON);    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:NumberAxisTests.java

示例5: testXYAutoRange2

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Checks that the auto-range for the range axis on an XYPlot is
 * working as expected.
 */
public void testXYAutoRange2() {
    XYSeries series = new XYSeries("Series 1");
    series.add(1.0, 1.0);
    series.add(2.0, 2.0);
    series.add(3.0, 3.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Test", 
        "X",
        "Y",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(0.9, axis.getLowerBound(), EPSILON);    
    assertEquals(3.1, axis.getUpperBound(), EPSILON);    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:NumberAxisTests.java

示例6: testAxisMargins

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Tests the the lower and upper margin settings produce the expected 
 * results.
 */
public void testAxisMargins() {
    XYSeries series = new XYSeries("S1");
    series.add(100.0, 1.1);
    series.add(200.0, 2.2);
    XYSeriesCollection dataset = new XYSeriesCollection(series);
    dataset.setIntervalWidth(0.0);
    JFreeChart chart = ChartFactory.createScatterPlot(
        "Title", "X", "Y", dataset, PlotOrientation.VERTICAL, 
        false, false, false
    );
    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Range r = domainAxis.getRange();
    assertEquals(110.0, r.getLength(), EPSILON);
    domainAxis.setLowerMargin(0.10);
    domainAxis.setUpperMargin(0.10);
    r = domainAxis.getRange();
    assertEquals(120.0, r.getLength(), EPSILON);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:ValueAxisTests.java

示例7: GenerateRTMapPNG

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException {
    new File(Workfolder + "/RT_Mapping/").mkdir();
    String pngfile = Workfolder + "/RT_Mapping/" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSA.mzXMLFileName).length() - 1)) + "_" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSB.mzXMLFileName).length() - 1)) + "_RT.png";

    XYSeries smoothline = new XYSeries("RT fitting curve");
    for (XYZData data : regression.PredictYList) {
        smoothline.add(data.getX(), data.getY());
    }
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "RT:" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName), "RT:" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName), xySeriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}
 
開發者ID:YcheCourseProject,項目名稱:DIA-Umpire-Maven,代碼行數:26,代碼來源:RTAlignedPepIonMapping.java

示例8: writeROCCurveOfTopRank

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public double[] writeROCCurveOfTopRank(File outputFile, double step, String add) throws Exception{
	double AUC=0;
	double F=0;
	int countF=0;
	TreeMap<Double, List<MatchType>> topScoringMatches=new TreeMap<Double,List<MatchType>>(Collections.reverseOrder());
	int[][] sortedIndizes=getIndizesOfSortedScores();
	int allPositives=0;
	int allNegatives=0;

	for(int i=0;i<sortedIndizes.length;i++){
		int ind=sortedIndizes[i][0];
		double value=getSimilarityValue(i,ind);
		if(Double.isNaN(value))continue;
		if(!topScoringMatches.containsKey(value))topScoringMatches.put(value, new ArrayList<MatchType>());			
		if(massbankQuery.get(i).hasEqualInChiKey(massbankDB.get(ind))){
			topScoringMatches.get(value).add(MatchType.TruePositiveMatch);
			allPositives++;
		}else{
			topScoringMatches.get(value).add(MatchType.FalsePositiveMatch);
			allNegatives++;
		}
	}

	List<double[]> values=new ArrayList<double[]>();
	XYSeriesCollection dataset = new XYSeriesCollection();
	XYSeries series=new XYSeries("ROCCurve " + getMethodsQueryAndDBString());
	double currentNumberTruePositives=0;
	double currentNumberFalsePositives=0;
	for(Entry<Double, List<MatchType>> matches:topScoringMatches.entrySet()){
		for(MatchType m:matches.getValue()){
			if(m.equals(MatchType.TruePositiveMatch))currentNumberTruePositives++;
			if(m.equals(MatchType.FalsePositiveMatch))currentNumberFalsePositives++;
		}

		double sensitivity=1.0*currentNumberTruePositives/allPositives;
		double EinsMinusSpecificity=1.0*currentNumberFalsePositives/allNegatives;
		values.add(new double[]{EinsMinusSpecificity,sensitivity});
		series.add(EinsMinusSpecificity,sensitivity);
		double precision=1.0*currentNumberTruePositives/(currentNumberTruePositives+currentNumberFalsePositives);
		F+=matches.getValue().size()*2*precision*sensitivity/(precision+sensitivity);
		countF+=matches.getValue().size();
	}
	dataset.addSeries(series);
	F/=countF;

	double lastX=0;		
	for(int i=1;i<values.size();i++){
		if(values.get(i-1)[0]!=values.get(i)[0]){
			AUC+=values.get(i-1)[1]*(values.get(i)[0]-lastX);
			lastX=values.get(i)[0];
		}
	}

	final JFreeChart chart = ChartFactory.createScatterPlot("ROCCurve","False Positive Rate", "True Positive Rate", dataset);
	ChartUtilities.saveChartAsJPEG(new File(outputFile.getAbsolutePath()+sep+add+"ROCCurveOfTopRank_"+getMethodsQueryAndDBString()+".jpg"), chart, 1000, 1000);

	return new double[]{AUC,F};
}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:59,代碼來源:SimilarityMatrix.java

示例9: writeQValues

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
private static List<double[]> writeQValues(File outputFile, List<File> inputFiles, double minQValue, double maxQValue, boolean normalizedEstimated) throws Exception{
	List<List<double[]>> r=getPoints(inputFiles, minQValue, maxQValue, true, false, "and", false, normalizedEstimated);
	Map<Integer,Map<Double, List<Double>>> allValues=new HashMap<Integer,Map<Double, List<Double>>>();
	XYSeriesCollection dataset = new XYSeriesCollection();
	List<double[]> result=new ArrayList<double[]>();
	for(int i=0;i<inputFiles.size();i++){
		XYSeries xyseries=new XYSeries(inputFiles.get(i).getName());
		for(int j=0;j<r.get(i).size();j++){
			double[] d=r.get(i).get(j);
			xyseries.add(d[0],d[1]);
			result.add(new double[]{d[0],d[1]});
			if(!allValues.containsKey(j))allValues.put(j,new TreeMap<Double,List<Double>>());
			if(!allValues.get(j).containsKey(d[0]))allValues.get(j).put(d[0], new ArrayList<Double>());
			allValues.get(j).get(d[0]).add(d[1]);
		}
		dataset.addSeries(xyseries);
	}


	Collections.sort(result,new Comparator<double[]>(){
		@Override
		public int compare(double[] o1, double[] o2) {
			int c=Double.compare(o1[0],o2[0]);
			if(c!=0)return c;
			return Double.compare(o1[1],o2[1]);
		}
	});

	XYSeries seriesWH=SimilarityMatrix.getBisectingLine(minQValue, maxQValue);
	dataset.addSeries(seriesWH);

	final JFreeChart chart = ChartFactory.createScatterPlot("qValue", "qValue calculated", "qValue by decoy database", dataset, PlotOrientation.VERTICAL, false, false, false);
	ChartUtilities.saveChartAsJPEG(outputFile, chart, 1000, 1000);

	return result;
}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:37,代碼來源:MainStatistics.java

示例10: main

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception{
	//load a labeled dataset from a file (here labels are Strings)
	LabeledDataset<String> set = CSVDatasetLoader.loadLabeled(new File("/home/hugo4715/samples/sample2.csv"));
	
	//create a PerceptronClassifier using the dataset, this classifier is trained in the constructor
	PerceptronClassifier<String> classifier = new PerceptronClassifier<>(set);

	//create a map to store the series
	Map<Label<String>,Pair<List<Double>,List<Double>>> series = new HashMap<>();//label -> (set of x, set of y)
	
	//for each point, get its label and add it to the good series
	for(double[] point : set.getContent()){
		//get the label
		Label<String> out = classifier.classify(point).entrySet().stream().sorted(Map.Entry.comparingByValue()).findFirst().get().getKey();

		//add the points to the label set
		Pair<List<Double>,List<Double>> data = series.get(out);
		if(data == null)data = new Pair<>(new ArrayList<>(),new ArrayList<>());
		data.getLeft().add(point[0]);
		data.getRight().add(point[1]);
		series.put(out, data);
	}
	
	//show the series
	
	DefaultXYDataset d = new DefaultXYDataset();
	for(Entry<Label<String>, Pair<List<Double>, List<Double>>> s : series.entrySet()){
		double[] xSeries = s.getValue().getLeft().stream().mapToDouble(x -> x).toArray();
		double[] ySeries = s.getValue().getRight().stream().mapToDouble(y -> y).toArray();
		
		d.addSeries(s.getKey().getValue(), new double[][]{xSeries,ySeries});
	}
	

	//show the dataset using jfreechart
	final JFreeChart pieChart = ChartFactory.createScatterPlot("title", "x","y", d);
	final ChartPanel cPanel = new ChartPanel(pieChart);
	JOptionPane.showMessageDialog(null, cPanel);

}
 
開發者ID:hugo4715,項目名稱:Learn4J,代碼行數:41,代碼來源:PerceptronClassifierExample.java

示例11: scatterPlot

import org.jfree.chart.ChartFactory; //導入方法依賴的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

示例12: main

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception{
	
	//create the config using the builder
	LinkageClustererConfig config = LinkageClustererConfig.builder()
			.distance(new EuclidianSquaredDistance())//choose a distance measure
			.clusterAmount(3)//try to find clusters
			.build();

	Clusterer c = new SingleLinkageClusterer(config);
	
	//load a dataset
	Dataset s = CSVDatasetLoader.load(new File("/home/hugo4715/sample.csv"));

	Dataset[] result = c.cluster(s);
	
	DefaultXYDataset d = new DefaultXYDataset();
	//fill the XY dataset
	for (int i = 0; i < result.length; i++) {
		double[] x = new double[result[i].getContent().size()];
		double[] y = new double[result[i].getContent().size()];
		
		for(int l = 0; l < x.length;l++){
			x[l] = result[i].getContent().get(l)[0];
			y[l] = result[i].getContent().get(l)[1];
		}
		d.addSeries((Comparable)i, new double[][]{x,y});
	}
	
	//show the dataset using jfreechart
	final JFreeChart pieChart = ChartFactory.createScatterPlot("title", "x","y", d);
	final ChartPanel cPanel = new ChartPanel(pieChart);
	JOptionPane.showMessageDialog(null, cPanel);
}
 
開發者ID:hugo4715,項目名稱:Learn4J,代碼行數:34,代碼來源:SingleLinkageClustererExample.java

示例13: main

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception{
	
	//create the config using the builder
	DBSCANClustererConfig config = DBSCANClustererConfig.builder()
			.distance(new EuclidianSquaredDistance())//choose a distance measure
			.minDistance(3)//count all neighbours within the distance of a point
			.minDensity(4)//how many neighbours are needed for a point to be a core point
			.build();

	Clusterer c = new DBSCANClusterer(config);
	
	//load a dataset
	Dataset s = CSVDatasetLoader.load(new File("/home/hugo4715/sample.csv"));

	Dataset[] result = c.cluster(s);
	
	DefaultXYDataset d = new DefaultXYDataset();
	//fill the XY dataset
	for (int i = 0; i < result.length; i++) {
		double[] x = new double[result[i].getContent().size()];
		double[] y = new double[result[i].getContent().size()];
		
		for(int l = 0; l < x.length;l++){
			x[l] = result[i].getContent().get(l)[0];
			y[l] = result[i].getContent().get(l)[1];
		}
		d.addSeries((Comparable)i, new double[][]{x,y});
	}
	
	//show the dataset using jfreechart
	final JFreeChart pieChart = ChartFactory.createScatterPlot("title", "x","y", d);
	final ChartPanel cPanel = new ChartPanel(pieChart);
	JOptionPane.showMessageDialog(null, cPanel);
}
 
開發者ID:hugo4715,項目名稱:Learn4J,代碼行數:35,代碼來源:DBSCANClustererExample.java

示例14: updateChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public void updateChart(double[] data) {

		this.removeAll();
		this.revalidate();

		series = new XYSeries("XYGraph");
		for(int i=0; i<data.length;i++){
			if(data[i]>-1){
				series.add(5*i , data[i]/255 );
			}
		}

		dataset = new XYSeriesCollection();
		dataset.addSeries(series);


		chart = ChartFactory.createScatterPlot(
				null, // Title
				"ω [rad/s]", // x-axis Label
				"Q / Qmax", // y-axis Label
				dataset, // Dataset
				PlotOrientation.VERTICAL, 
				false, // Show Legend
				true, // Use tooltips
				false // Configure chart to generate URLs?
				);
		XYPlot plot = (XYPlot) chart.getPlot();
		plot.setBackgroundPaint( Color.WHITE );

		XYItemRenderer renderer = plot.getRenderer();
		renderer.setSeriesPaint(0, Color.RED);
		double delta = 2.0;
		Shape shape1 = new Rectangle2D.Double(-delta, -delta, delta, delta);
		renderer.setSeriesShape(0, shape1);

		ValueAxis yAxis = plot.getRangeAxis();
		yAxis.setRange(0, 1.1);
		ValueAxis xAxis = plot.getDomainAxis();
		xAxis.setRange(0, 2000);

		ChartPanel cp = new ChartPanel(chart);
		cp.setBackground(Color.WHITE);

		this.setLayout(new BorderLayout());
		this.add(cp, BorderLayout.CENTER);
		this.repaint();

	}
 
開發者ID:Tosbert,項目名稱:FizeauExperimentSimulation,代碼行數:49,代碼來源:GraphPanel.java

示例15: main

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception{
	
	//create the config using the builder
	KMeansClustererConfig config = KMeansClustererConfig.builder()
			.distance(new EuclidianSquaredDistance())//choose a distance measure
			.clusterAmount(2)//try to find clusters
			.build();

	Clusterer c = new KMeansPlusPlusClusterer(config);
	
	//load a dataset
	Dataset s = CSVDatasetLoader.load(new File("/home/hugo4715/sample.csv"));

	Dataset[] result = c.cluster(s);
	
	DefaultXYDataset d = new DefaultXYDataset();
	//fill the XY dataset
	for (int i = 0; i < result.length; i++) {
		double[] x = new double[result[i].getContent().size()];
		double[] y = new double[result[i].getContent().size()];
		
		for(int l = 0; l < x.length;l++){
			x[l] = result[i].getContent().get(l)[0];
			y[l] = result[i].getContent().get(l)[1];
		}
		d.addSeries((Comparable)i, new double[][]{x,y});
	}
	
	//show the dataset using jfreechart
	final JFreeChart pieChart = ChartFactory.createScatterPlot("title", "x","y", d);
	final ChartPanel cPanel = new ChartPanel(pieChart);
	JOptionPane.showMessageDialog(null, cPanel);
}
 
開發者ID:hugo4715,項目名稱:Learn4J,代碼行數:34,代碼來源:KMeanClustererExample.java


注:本文中的org.jfree.chart.ChartFactory.createScatterPlot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。