-
Notifications
You must be signed in to change notification settings - Fork 14
breeze-viz gives HeadlessException under Databricks #9
Comments
set f.visible = false before doing anything else On Mon, Aug 24, 2015 at 11:54 AM, Sujit Pal [email protected]
|
Thanks David. I did as you suggested, adding your suggestion after the Figure instantiation, ie: val f = Figure()
f.visible = false
... The stack trace is a bit different now, looks like it now fails the headless check at the visible setting line (ie the line you suggested).
|
I guess it doesn't work :( It would be good to be fixed, but i don't have bandwidth to work on viz On Mon, Aug 24, 2015 at 1:56 PM, Sujit Pal [email protected] wrote:
|
Yes, I guess I will go back to doing what I am doing now. Either use the somewhat anemic visualization built into Databricks around DataFrames, or save the output data and build a separate Python notebook to visualize. Not ideal, but works. I can close the issue if you want unless this serves as a reminder to come back to it when you have some time? |
yeah, let's leave it open. I have hopes someone will come and fork it and be done with it. On Mon, Aug 24, 2015 at 3:56 PM, Sujit Pal [email protected] wrote:
|
I got this working (you don't need to change anything in Breeze). The result of the code below is an HTML snippet that can be embedded in a webpage to show a plot image inline. Credit goes to https://github.com/wookietreiber/scala-chart for helping me learn how to do it (they have a good library for Scala vizualization as well, also using JFreeChart). The key is to make sure you don't use Figure from Breeze since that tries to display stuff. import breeze.plot._
import breeze.linalg._
val x = linspace(0.0,1.0,101)
val p = new Plot()
p +=plot(x, x :^ 2.0)
p.xlabel = "x axis"
p.ylabel = "y axis"
val img = p.chart.createBufferedImage(600,600,java.awt.image.BufferedImage.TYPE_INT_ARGB,null )
import org.jfree.chart.encoders.EncoderUtil
val imgDisplaySz=(600,600)
import org.apache.commons.codec.binary.Base64
val imageDataString = Base64.encodeBase64String(EncoderUtil.encode(img, "png"))
val imgHeight = imgDisplaySz._1
val imgWidth = imgDisplaySz._2
val imgTag = s"""<img height="$imgHeight" width="$imgWidth" src="data:image/png;base64,$imageDataString" />""" |
@praveen-srinivasan: Did you get this working on Databricks? If so, can you please share the Databricks version and if you had to do anything special with the environment, such as importing extra libraries, etc? I ask because I tried with and without importing the breeze-viz libraries and I get back an error that I saw long back which indicates that there is some classpath conflicts between the breeze built in with Spark and the one I added. |
Not on databricks - didn't try there.
|
I used X virtual framebuffer and it works perfectly. |
After that it is easy to:
and...
|
I'm running into the same issue in an Apache Zeppelin notebook. |
If you want to save plot as an image file, I use the following code
with this code, you don't need to create Figure, and don't need to mess up with system display environment. |
@zhoulu312 It works! |
I tried importing breeze-viz-2.10-0.11.2 into a Databricks environment. Here is a code snippet I used to test basic operations.
It gives me the following exception:
I read some Stack Overflow posts advising to explicitly set java.awt.headless to true, but it doesn't seem to have any effect. Also java.awt.GraphicsEnvironment.isHeadless() returns true.
My environment is Databricks version 2.0.1 running Scala 2.10.4 and Oracle Java 1.7.0_65.
Is breeze-viz suitable for use in a notebook environment such as Databricks? It would be nice to use with Scala notebooks (similar to matplotlib with Python notebooks).
The text was updated successfully, but these errors were encountered: