-1

Code:

g.filter(join_month == "2008.03").nodes.color = red

Why doesn't the following work?

g.filter(join_month == "2008.03").nodes.color = #FFFFFF

Do I just have the format of the hexadecimal color wrong?

user4157124
  • 2,809
  • 13
  • 27
  • 42
ibakecookies
  • 144
  • 2
  • 6
  • 1
    `#FFFFFF` is not a valid hexidecimal format in Python. Use `0xFFFFFF` –  Mar 06 '13 at 20:09
  • what's the output of just typing `red` in the console? – Lynn Mar 06 '13 at 20:09
  • There's no output when I type `red`. It changes the color of the node in the graph to red. This is what happens when I use `0xFFFFFF`: `g.filter(join_month == "2008.03").nodes.color = 0xFFFFFF Traceback (most recent call last): File "", line 1, in ClassCastException: java.lang.ClassCastException: org.python.core.PySingleton cannot be cast to java.awt.Color` – ibakecookies Mar 06 '13 at 20:25
  • @user1604416 It looks like the error is coming from Jython. I've attached an answer that should solve the problem. I don't have Gephi installed to test... if those answers don't work for you, please reply using @ at the start of your comment This alerts me to your response. (I did not see the previous response until I randomly revisited this question.) –  Mar 06 '13 at 21:20

1 Answers1

0

Gephi seems to be using Jython as the basis for its Python Interpreter.

You should be able to get your desired result by creating a java.awt.Color object and passing your hex value to the constructor, like so:

>>> from java.awt import Color
>>> mycolor = Color(0xFFFFFF)
>>> g.filter(join_month == "2008.03").nodes.color = mycolor

According to an example found here it looks like another way to do this is to use Gephi's color class.:

>>> red = 0xFF
>>> green = 0xFF
>>> blue = 0xFF
>>> g.filter(join_month == "2008.03").nodes.color = color(red, green, blue)