Java - Ayuda con JFreeChart

 
Vista:

Ayuda con JFreeChart

Publicado por Erika (8 intervenciones) el 25/11/2008 23:34:33
import java.awt.Font;
import javax.swing.*;
import java.awt.Color;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.xy.XYSeries;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.xy.XYAreaRenderer;

public class DistribucionNormal2 extends JFrame{

public DistribucionNormal2(){
super("Distribución Normal");

String Titulo = "Graficas de Distribución Normal";
String SubTitulo = "Mediana 0 y 1.5";
boolean theLegend = false;
String VAxisText ="Velocs. Máxs. (kph)";
XYSeries serie1 = new XYSeries("Mediana 0");
XYSeries serie2 = new XYSeries("Mediana 1.5");
XYSeries serie3 = new XYSeries("");

double fx = 0;
double fx2 = 0;
double Gamma = 0.55; //Desviación
double fMedia1 =0.0;
double fMedia2 =1.5;

for (Double i=-3.0;i<=3;i+=0.005)
{
fx=(Math.exp((-0.5)*Math.pow((i-fMedia1)/Gamma,2)))/(Gamma*Math.sqrt(2*Math.PI));
serie1.add((Double)i,(Double)fx);

fx=(Math.exp((-0.5)*Math.pow(((i+1.5)-fMedia2)/Gamma,2)))/(Gamma*Math.sqrt(2*Math.PI));
serie2.add((Double)(i+1.5),(Double)fx);
}

for(Double i=-3.0;i<=0.75-1.5;i+=0.005){
fx=(Math.exp((-0.5)*Math.pow(((i+1.5)-fMedia2)/Gamma,2)))/(Gamma*Math.sqrt(2*Math.PI));
serie3.add((Double)(i+1.5),(Double)fx);
}

for(Double i=0.75;i<=3;i+=0.005){
fx2=(Math.exp((-0.5)*Math.pow((i-fMedia1)/Gamma,2)))/(Gamma*Math.sqrt(2*Math.PI));
serie3.add((Double)(i),(Double)fx2);
}

XYSeriesCollection curvasXY = new XYSeriesCollection();
curvasXY.addSeries(serie3);
curvasXY.addSeries(serie2);
curvasXY.addSeries(serie1);

JFreeChart chart = ChartFactory.createXYLineChart(Titulo,VAxisText,"Pf",curvasXY,PlotOrientation.VERTICAL,theLegend,true,true);

XYAreaRenderer renderer = new XYAreaRenderer();

renderer.setSeriesPaint(0,Color.black);
renderer.setSeriesPaint(1,Color.blue);
renderer.setSeriesPaint(2,Color.blue);

XYPlot plot = chart.getXYPlot();
plot.setRenderer(renderer);

ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(300,300));
setContentPane(chartPanel);
}

public static void main(String[] args){
DistribucionNormal2 apli = new DistribucionNormal2();
apli.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
apli.setSize(600,350);
apli.setLocation(400,300);
apli.show();
}
}

Necesito que solo la serie3 aparezca con color, es decir que solo la interseccion de las graficas tenga color. Ojala alguien pudiera ayudarme
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder