This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Open Source Projects and the fly likes Drawing graphs for mathematical functions using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Drawing graphs for mathematical functions using Java" Watch "Drawing graphs for mathematical functions using Java" New topic
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: 139
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: 139
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Drawing graphs for mathematical functions using Java