有没有办法在Jupyter笔记本中为Scala使用任何类型的绘图,如Matplotlib for Python?
感谢。
答案 0 :(得分:0)
对于Bluemix上的Scala笔记本,我主要使用两个绘图库(按照优先顺序):
// Example Scala Cell invocation %%brunel data('https://raw.githubusercontent.com/Brunel-Visualization/Brunel/master/python/examples/data/whiskey.csv') point x(Rating) y(Age) bin(Rating,Age)
供参考,以下是一些示例Scala笔记本示例:example 1 example 2
/** Load Lightning Scala Client for Visualizations */ %AddJar https://github.com/joshisa/lightning-scala/raw/master/dist/lightning-scala_2.10-0.2.0.jar -f import org.viz.lightning._ import scala.util.Random // host should not contain a trailing slash val lgn = Lightning(host="https://lightningviz.mybluemix.net"); lgn.auth = None lgn.createSession() println("Woot!, we have a lightning viz object. Bazinga!"); println(""); val x = Array.fill(100)(Random.nextDouble()); val y = Array.fill(100)(Random.nextDouble()); val somegroup = Array.fill(100)(Random.nextFloat() * 5).map(_.toInt); val somelabels = (Array("point 0", "point 1", "point 2", "point 3", "point 4", "point 5", "point 6", "point 7", "point 8", "point 9", "point 10", "point 11", "point 12", "point 13", "point 14", "point 15", "point 16", "point 17", "point 18", "point 19", "point 20", "point 21", "point 22", "point 23", "point 24", "point 25", "point 26", "point 27", "point 28", "point 29", "point 30", "point 31", "point 32", "point 33", "point 34", "point 35", "point 36", "point 37", "point 38", "point 39", "point 40", "point 41", "point 42", "point 43", "point 44", "point 45", "point 46", "point 47", "point 48", "point 49", "point 50", "point 51", "point 52", "point 53", "point 54", "point 55", "point 56", "point 57", "point 58", "point 59", "point 60", "point 61", "point 62", "point 63", "point 64", "point 65", "point 66", "point 67", "point 68", "point 69", "point 70", "point 71", "point 72", "point 73", "point 74", "point 75", "point 76", "point 77", "point 78", "point 79", "point 80", "point 81", "point 82", "point 83", "point 84", "point 85", "point 86", "point 87", "point 88", "point 89", "point 90", "point 91", "point 92", "point 93", "point 94", "point 95", "point 96", "point 97", "point 98", "point 99")); val somesize = Array.fill(100)(Random.nextDouble() * 20 + 5); val xaxis = "example x-axis label"; val yaxis = "example y-axis label"; val alpha = Array(0.6); val viz = lgn.scatter(x, y, somegroup, labels=somelabels, alpha=alpha, size=somesize, xaxis=xaxis, yaxis=yaxis); val vizhtml = viz.getHTML kernel.magics.html(s""" ${vizhtml} """);