• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drawing graphs for mathematical functions using Java

 
udayshankar kintali
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic