Does clojure have any libraries for showing dynamic plots/charts, something as simple as oscillating sine wave for example?
Looked at incanter library, but it seems to only provide static plots.
Not really a plotting library, but you could use the quil interface to the Java Processing library.
If you're willing to use Clojurescript, I'd suggest looking at d3.js and the strokes library for using it from Clojurescript. However, this requires learning d3.js's quirky methodology, and will require quite a bit of thinking in terms of HTML, DOM, CSS, and Javascript even if you write most of the code in Clojure. [EDIT: I now think it's simpler to use d3.js directly from Clojurescript; strokes provides little benefit. There are also some Clojurescript chart libraries built on d3.js. I've found NVD3 useful, for example.]
There's also an all-Clojurescript C2 library, designed to implement some of the functionality of d3.js, but doesn't allow dynamic plotting, though you can add dynamic features using custom CSS. (C2 is not really growing, AFAIK, but it's actively maintained.)
Another option, which might actually be easier (or not) would be to use a Java library that does what you want. No doubt there are several, including JFreeChart. This also might require a bit of thinking Java-style, learning about Clojure-Java interop (which ranges from trivially easy to ugly, confusing, and verbose, depending on how the Java library is structured).
For whatever it's worth, there are libraries for interfacing Java with R, which has very nice plotting capabilities through it's built-in plotting, the ggplot2 library, and the lattice library. So in theory, you could use Clojure to control Java to control R, which may not be worth it. See this question for Java-to-R libraries.
You should also ask on the Incanter Google group. Maybe there are some hidden tricks, or something in development that will do what you want.
EDIT: Incanter does provide something called "dynamic plots". Not exactly what you want, I think: These are charts that have parameters attached to sliders so that you can see plot change over time. Nevertheless, the fact that Incanter can do this suggests that it might not be that difficult to create a chart that dynamically changes in response to changes in data.
ONE MORE EDIT: Since JFreeChart is what Incanter uses to draw charts, and JFreeChart is a Java library that is able to generate dynamic charts, an option is to use Java methods on the chart objects that Incanter produces, as this answer suggests.
(EDIT: A search for "clojure jfreechart" turns up a few libraries and tutorials intended to help one use JFreeChart with Clojure.)
Anndd ... one more EDIT: https://github.com/liebke/apogee looks like it may be exactly what you wanted, jyriand. (I'm interested in related questions, and I keep noticing new potential answers to this one.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With