Plotting an arbitrary function:

Let us plot y = 2x2 - 10.0 over x = -10.0 through 10.0.

The Applet code is

public class TestPlot extends Applet {

public void init() {
PlotCanvas plot = new PlotCanvas();
plot.resize(150,150);
}

}

The Function data is

class MyData extends FunctionData {

protected double f (double x, double p) {

return 2.0 * x * x -10.0;

}

protected void setXRange() {

setXRange(-10.0, 10.0);

}

}

The applet output is:

Plotting a family of curves using a parameterized function:

Let us plot

y = 0.3 x3 + p

over x = -10.0 thru 10.0 for p = -20, 10, 40, 70, and 100.

The applet code is:

public class TestPlot2 extends Applet {

public void init() {

PlotCanvas plot = new PlotCanvas();

plot.resize(150,150);

}

}

The function data code is:

class MyData2 extends FunctionData {

protected double f(double x, double p) {

return 0.3 * x * x * x + p;

}

protected void setXRange() {

setXRange(-5.0, 10.0);

}

public double[] getParam() {

double[] p = new double[5];

p[0] = -20.0;

for ( int i=1; i<5; i++)

p[i] = p[i-1] + 30.0;

return p;

}

}

The applet output is:

Plotting the curve that corresponds to the parameter's current value:

In the family of curves, suppose we wish to plot a curve corresponding to the 'current' parameter value, p = -50.0, then

The applet code:

public class TestPlot3 extends Applet {

public void init() {

PlotCanvas plot = new PlotCanvas();

plot.resize(150,150);

plot.getData().setCurrentP(-50.0);

}

}

My function data same as above, but with the current curve capability:

class MyData3 extends MyData2 {

public boolean isCurrentDrawable() {

return true;

}

}

The output of this applet is:

Placing a SPOT corresponding to current parameter and x-vaules:

In the above applet, say we want to show where the current parameter value (p = -50) and x-value (x=-2.5) is.

the applet code is:

public class TestPlot4 extends TestPlot3 {

public void init() {

super.init(); //does the same as the applet above

Component[] comps = getComponents(); //list of all comps in this app

DataWrapper data;

for (int i=0; i<comps.length; i++)

if (comps[i] instanceof PlotCanvas) { //if the comp is PlotCanvas obj

data = ((PlotCanvas)comps[i]).getData();

data.showCurrentSpot(true);

data.setCurrentX(-2.5);

}

}

}

// The applet output is:

Plotting two distinct functions:

Let us plot the curve, y = 2 x2 -10.0 (same as the first example above), and a family of curves, y = 0.3 x3 + p where p is given in the second example above.

The applet code is:

public class TestPlot5 extends Applet {

public void init() {

PlotCanvas plot = new PlotCanvas();

plot.addData(new MyData2()); //the curve family in 2nd example

Data d = new MyData(); //the single curve in the 1st example

d.setColor(Color.red); //change to a different color

d.setColor(Color.red);

plot.resize(150,150);

}

}

Its output is:

Profiles of Excess Minority Carrier Concentration and the associated Minority carrier diffusion current.

The minority hole concentration profile in n-type side of the pn junction is given by:

p(x) = pn0 * ( exp(qV/kT) - 1.0 ) * ( sinh(W - x)/sinh(W) ) + pn0 * ( 1.0 - sinh(x)/sinh(W) );

where pn0 is the equil. hole concentration, and W is the thickness of the n-type side.

The applet output is:

The associated diffusion current is

Jp(x) = - q Dp dp(x)/dx
= A ( exp(qV/kT) - 1.0 ) * cosh(W - x)/sinh(W) + A cosh(x)/sinh(W)
where, A = q * pn0 * Dp / Lp

The applet output is:

Setting axis scale manually:

Use Axis.setAutoScale(false), Axis.setRangeX(), and Axis.setRangeY();

The applet output is:

Log Plot:

Use Axis.setXLog(true) and/or Axis.setYLog(true).

An example plot is: