• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Drawing graphs for mathematical functions using Java

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic