| Author |
Drawing graphs for mathematical functions using Java
|
udayshankar kintali
Greenhorn
Joined: Jan 15, 2012
Posts: 15
|
|
Hi All,
I want to draw graphs for mathematical functions (trigonometric function) using Java and also determine the minimum and maximum values for that function. Can anyone please suggest the API to be used and some sites where I can get some samples.
I came across this API called jGraphT , how effective is that?
|
 |
John Vorwald
Ranch Hand
Joined: Sep 26, 2010
Posts: 96
|
|
I'm not sure what you are looking for, but JFreeChart has a number of chart types. Here's one place to look at samples. http://www.java2s.com/Code/Java/Chart/CatalogChart.htm
Also, google for jfreechart tutorial.
|
 |
udayshankar kintali
Greenhorn
Joined: Jan 15, 2012
Posts: 15
|
|
Hi John,
I have to draw a graph for a mathematical function.
Let us say I have to draw a graph for sine function, that is my question. I hope I am clear on that.
|
 |
John Vorwald
Ranch Hand
Joined: Sep 26, 2010
Posts: 96
|
|
Try this example
http://www.java2s.com/Code/Java/Chart/JFreeChartXYSeriesDemo.htm
Change the lines like
series.add(1.0, 500.2);
to something like
for (double xValue = xMin; xValue <= xMax; xValue+=dX) {
double yValue = f(xValue);
series.add(xValue, yValue);
}
But, you may need to allocate an array for the x/y values so that the values remain.
Or, this example may be easier to implement, since the x/y are assigned to a dataset in a separate function.
http://www.java2s.com/Code/Java/Chart/JFreeChartWaterTemperatureDemo.htm
I do this quite a bit, making various types of charts using jFreeChart.
Good Luck
John
|
 |
 |
|
|
subject: Drawing graphs for mathematical functions using Java
|
|
|