# Help with graph code example

• 07-29-2007, 12:45 AM
silvia
Help with graph code example
Hi, I've been trying so long and i could not solve any of the problems (below) that I've been having for some time. If any of you could help out with any of the problems, that's be absolutely amazing.

1. Graph Class Library
that's the website from which i got my plotting codes/classes for a plot that supposedly takes a set of data from a different calculating program (example 3 code is the one where you can load data). I'm looking at the graph code example3 and it's not obvious to me how to call up the data for the graph. is it where it says "DATA"? if the data file is called output.txt would i just substitute "output.txt" for "DATA"?
2. How would i make it so that my outout.txt file from a calculating program is composed of two columns (so basically a set of data, x coordinates and y coordinates)?
3. In the following equation, i want P to be varying b/t two given constants Pmax and Pmin. how would i do that?

public double I0(double Vb, double P, double Pbath) {
return ((Pbath-P)/Vb);
}

Thanks
• 07-29-2007, 10:16 PM
hardwired
I'm looking at the graph code example3 and it's not obvious to me how to call up the data for the graph. is it where it says "DATA"?
This line in the applet
Code:

`String data  = getParameter("DATA");`
reads the data file name from the applet tag. To find it you look at the source (View menu/Page -> "view source") and find that the applet is in the middle row of a frameset. Copy the url ("example3_app.html") for this frame and load it into the address bar. The applet tag has the param tag
Code:

```<param name=data       value="elliptical.data">```
which shows the data file name for the applet.
if the data file is called output.txt would i just substitute "output.txt" for "DATA"?
If you want to use the applet tag and its param tag you would substitute "output.txt" for the value of "elliptical.data". If you want to put it directly into the applet you could write
Code:

`String data  = "output.txt";`
How would i make it so that my outout.txt file from a calculating program is composed of two columns (so basically a set of data, x coordinates and y coordinates)?
Make up a BufferedWriter to write the data out to the "output.txt" file. For each x, y value skip a space in between and after the pair write a newline with myWriter.newLine().
In the following equation, i want P to be varying b/t two given constants Pmax and Pmin. how would i do that?
Let's say you have data 250 <= x <= 1000 and want to scale it into 50 <= y <= 100.
To scale the units
Code:

```        100 - 50 scale = ----------         1000 - 250 Scale the x interval and add the minimum y value.     50(x - 250) y = ----------- + 50         750```