Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to modify color or shape of nodes in graph #2672

Closed
dahrs opened this issue May 11, 2018 · 1 comment
Closed

Unable to modify color or shape of nodes in graph #2672

dahrs opened this issue May 11, 2018 · 1 comment

Comments

@dahrs
Copy link

dahrs commented May 11, 2018

Hi,
I'm new to holoviews, but I've found a way to plot the graph I need from an edge list with weights and all, just like I need it. Now I'm trying to find a way to change the color or shape of the source nodes. But I'm unable to do so because I get a weird error:

Traceback (most recent call last): File "testDatashaderHoloviews.py", line 154, in <module> myGraphTestSpringLayout() File "testDatashaderHoloviews.py", line 133, in myGraphTestSpringLayout style=dict(cmap=['blue', 'red'])) File "/u/alfonsda/anaconda3/lib/python3.6/site-packages/holoviews/core/dimension.py", line 1145, in opts backend_options = Store.options(backend=backend) File "/u/alfonsda/anaconda3/lib/python3.6/site-packages/holoviews/core/options.py", line 1059, in options return cls._options[backend] KeyError: 'matplotlib'
I just don't understand what the problem or if there's an easier way to change a selected group of nodes while uploading it from my edge list. I hope there's a solution because the library is really complete and well made.
Here is my code:
`

def myGraphTestSpringLayout():

g = nx.read_edgelist("./myGraphEdgeList.tsv", delimiter='\t', nodetype=str, data=(('weight',float), ('color',str)))

padding = dict(x=(-1.2, 1.2), y=(-1.2, 1.2))

myGraph = hv.Graph.from_networkx(g, nx.spring_layout, nodes=None, weight='weight')

myGraph.opts(plot=dict(color_index='Type', edge_color_index='Weight'),
                              style=dict(cmap=['blue', 'red']))

hv.renderer('bokeh').save(myGraph,'out')`

Thanks in advance,

@philippjfr
Copy link
Member

@dahrs It looks like you have to load the bokeh extension before you start defining options. You can either declare the extension at the top:

hv.extension('bokeh')

or move the renderer declaration to the top:

renderer = hv.renderer('bokeh')

Additionally it seems like you are trying to extract the node edge attributes, something that isn't supported currently but will be once #2714 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants