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

Labels do not show #185

Closed
aarondodell opened this issue Jul 10, 2018 · 5 comments
Closed

Labels do not show #185

aarondodell opened this issue Jul 10, 2018 · 5 comments

Comments

@aarondodell
Copy link

Labels are not showing on for igraph for some reason. I've included code below, which is almost line for line from the Tutorial.

import igraph as ig

g = ig.Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)])

g.vs["name"] = ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]
g.vs["age"] = [25, 31, 18, 47, 22, 23, 50]
g.vs["gender"] = ["f", "m", "f", "m", "f", "m", "m"]
g.es["is_formal"] = [False, False, True, True, True, False, True, False, False]

layout = g.layout_kamada_kawai()

g.vs["label"] = g.vs["name"]
color_dict = {"m": "blue", "f": "pink"}
g.vs["color"] = [color_dict[gender] for gender in g.vs["gender"]]

ig.plot(g, layout = layout, bbox = (300, 300), margin = 20)

This code produces the following graph for me, which has everything except for the labels.

igraph_issue

All of my igraph and Cairo should be up to date as well.

cairo.version
Out[3]: '1.17.1'

ig.__version__
Out[4]: '0.7.1+5.3b99dbf6'

I've also tried using keyword arguments to set the label, but that doesn't work either.

visual_style = {}
visual_style["vertex_size"] = 20
visual_style["vertex_color"] = [color_dict[gender] for gender in g.vs["gender"]]
visual_style["vertex_label"] = g.vs["name"]
visual_style["edge_width"] = [1 + 2 * int(is_formal) for is_formal in g.es["is_formal"]]
visual_style["layout"] = layout
visual_style["bbox"] = (300, 300)
visual_style["margin"] = 20
ig.plot(g, **visual_style)

igraph_issue2

I hope I've given you enough information to help, I cannot find anyone else with a Missing Labels issue.

@aarondodell
Copy link
Author

aarondodell commented Jul 10, 2018

My apologies, it looks like the Labels were not showing because I was graphing inline on iPython 6.4.0

Once I saved the file as an SVG, I was able to see the Labels.

capture

I'll leave it up to your discretion on what to do with this issue since I'm sure other people have had this issue before, or if it even merits a fix.

@aarondodell aarondodell changed the title Labels does not show Labels do not show Jul 10, 2018
@ntamas
Copy link
Member

ntamas commented Jul 11, 2018

Hmmm, could it be an issue with missing fonts somehow?

When you use the write_svg() method, igraph constructs an SVG file "manually". For all other plotting methods (including inline plots in IPython), igraph uses the Cairo library installed on your machine to take care of producing the plot -- igraph simply instructs Cairo to use the default sans-serif font on your system and leaves it up to Cairo to work out the details. So, all in all, this could be a Cairo-specific issue that has nothing to do with igraph itself. It would be helpful to know which platform you are using and what version of IPython (although I can't promise that I'll have time to set up an environment identical to yours to reproduce the problem in the near future).

@roblem
Copy link

roblem commented Aug 1, 2018

Also having this issue on Fedora 28 (in Anaconda python 3.6 Environment). Even using the write_svg() method results in no labels. Had to apply patch here to get inline images to show labels. Saved svg's still don't have them.

@ntamas
Copy link
Member

ntamas commented Jan 30, 2020

Even using the write_svg() method results in no labels.

This is interesting; write_svg() does not use Cairo and constructs an SVG file manually (it is used as a fallback in environments where the user wants to plot but does not have Cairo). If the issue still persists, can you post an example SVG file created with write_svg() that shows no labels for you?

@aarondodell
Copy link
Author

closing issue as no longer needed

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

3 participants