2015-12-17 89 views
3

有沒有一種方法可以在Jupyter筆記本中使用Scala中的任何類型的繪圖,比如用於Python的Matplotlib?Bluemix Apache Spark服務 - 爲scala繪圖?

謝謝。

+1

歡迎SO dzmitryk。請務必閱讀[我可以在這裏詢問什麼主題?](http://stackoverflow.com/help/on-topic)。特別是_Questions要求我們推薦或查找書籍,工具,軟件庫,教程或其他非現場資源,這些都是Stack Overflow_的主題。您可以嘗試http://softwarerecs.stackexchange.com/。 – zero323

回答

0

有關Bluemix斯卡拉筆記本電腦,我已經有兩個主要繪圖庫的工作(按優先順序排列):

  1. Brunel [推薦]:我建議使用布魯內爾因爲它已經內安裝筆記本服務器用於Bluemix。這樣就可以使用布魯內爾魔法命令%%布魯內爾
 

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

Brunel Point Bin Visualization

作爲參考,這裏有一些樣品的Scala筆記本的例子:example 1example 2

  • Lightning-Viz:對於Lightning-Viz,您需要一個自定義客戶端jar lightning-scala_2.10-0.2.0.jar,我已經重新編譯爲與Scala 2.10兼容。在您的斯卡拉細胞,你會做這樣的事情...
  •  
    
        /** 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} 
        """); 
    
    

    ​​

    相關問題