3 answers
A couple of weeks ago I ran into this problem myself, this library came to hand.
I was pleased to deal with it for long, because many examples are right there on the site + documentation, but this is if you decide to deeply understand.
 alex91, thanks! I'm going to try now.  Burunduk

It’s not completely clear what to draw ... If you have simple shapes, use Java 2D Graphics. And if you specifically draw different graphics, then there is a great lib JFreeChart .

An example of a program for outputting graphics of mathematical functions, the principle is simple  one point is calculated, and the second follows it one step back. Java lines are drawn between these points. Function graphs
