Clojure中的交互图和动态图/图表 [英] Interactve and dynamic plots/charts in clojure

查看:79
本文介绍了Clojure中的交互图和动态图/图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

clojure是否有用于显示动态图/图表的库,例如,像振荡正弦波一样简单?

Does clojure have any libraries for showing dynamic plots/charts, something as simple as oscillating sine wave for example?

看了incanter库,但它似乎只提供静态图。

Looked at incanter library, but it seems to only provide static plots.

推荐答案

不是真正的图库,但是您可以使用处理库的.com / quil / quil rel = nofollow noreferrer> quil 接口。

Not really a plotting library, but you could use the quil interface to the Java Processing library.

如果您愿意使用Clojurescript,建议您查看 d3.js strokes 库,以便在Clojurescript中使用它。但是,这需要学习d3.js的古怪方法,并且即使您使用Clojure编写了大部分代码,也需要在HTML,DOM,CSS和Javascript方面进行大量思考。

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.

还有一个全Clojurescript C2 库,旨在实现d3.js的某些功能,但不允许动态绘图,尽管您可以使用自定义CSS添加动态功能。 (AFAIK并没有真正实现C2的增长,但是它已经得到了积极维护。)

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.)

另一种选择实际上可能更容易(也可能不那么容易)是使用Java库,做你想要的。毫无疑问,其中有几种,包括 JFreeChart 。这可能还需要一些Java风格的思考,了解Clojure-Java互操作(根据Java库的结构,其范围从轻而易举到丑陋,混乱和冗长)。

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).

对于它的价值而言,有一些用于将Java与R接口的库,它通过内置的绘图,ggplot2库和点阵库具有非常好的绘图功能。因此,从理论上讲,您可以使用Clojure来控制Java来控制R,这可能不值得。有关Java到R库的信息,请参见此问题

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.

您还应该在Incanter Google网上论坛上提问。也许有一些隐藏的技巧,或者正在开发中的东西可以满足您的需求。

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.

编辑:Incanter确实提供了称为动态图 。我认为,这不完全是您想要的:这些图表的参数已附加到滑块,因此您可以查看绘图随时间的变化。尽管如此,Incanter可以做到这一点的事实表明,创建响应数据变化而动态变化的图表可能并不那么困难。

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.

更多编辑:由于Incanter使用JFreeChart绘制图表,而JFreeChart是能够生成动态图表的Java库,因此可以选择在Incanter生成的图表对象上使用Java方法,如此答案建议。

ONE MORE 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.

(编辑:搜索 clojure jfreechart会发现一些库和教程旨在帮助一个使用带有Clojure的JFreeChart的人。)

( A search for "clojure jfreechart" turns up a few libraries and tutorials intended to help one use JFreeChart with Clojure.)

Anndd ...还有一个编辑: https://github.com/liebke/apogee
看起来可能恰好是您想要的东西,jyriand。 (我对相关问题感兴趣,并且一直在关注这一问题的新答案。)

Anndd ... one more 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.)

这篇关于Clojure中的交互图和动态图/图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆