svg - Issue plotting vertex labels using igraph in ipython -


i work in ipython notebook, open on windows command

ipython qtconsole --matplotlib inline 

i'm using ipython qtconsole 3.0.0, python 2.7.9 , ipython 3.0.0.

i want plot graph, labels

from igraph import * g = graph.lattice([4,4],nei=1,circular=false) g.vs["label"]=[str(i) in xrange(16)] plot(g, layout="kk") 

in way, obtain inline plot of graph, there no labels , following message error each of missing labels

link glyph0-x hasn't been detected! 

where x integer number.

i tried specify labels directly inside plot() command, using vertex_label = ..., nothing works.

it seems me labels defined correctly , problem reside in ipython notebook and/or in modules uses plot graph. can kindly me issue?

i tried possible figure formats svg , png, using commands below, problem remains.

%config inlinebackend.figure_format = 'svg' %config inlinebackend.figure_format = 'png' 

the issue lies somewhere deep within guts of qt , svg implementations. setting figure format png not because igraph provides svg representation of graph objects only, suspect ipython creates svg representation first , rasterizes png. problem can solved right patching plot class in igraph/drawing/__init__.py; 1 has delete _repr_svg_ method class , add following method instead:

def _repr_png_(self):     """returns png representation of plot string.      method used ipython display plot inline.     """     # create new image surface , use png representation     surface = cairo.imagesurface(cairo.format_argb32, int(self.bbox.width),                                  int(self.bbox.height))     context = cairo.context(surface)     # plot graph on context     self.redraw(context)     # no idea why needed python crashes without     context.show_page()     # write png representation     io = bytesio()     surface.write_to_png(io)     # finish surface     surface.finish()     # return png representation     return io.getvalue() 

i'm bit uneasy modification in official code of python interface of igraph; svg representations in general nicer (and scalable), seems it's causing problems on windows , mac os x well. if reading post has more experience qt , svg implementation, i'd appreciate find root cause of bug keep svg representation of plots in igraph.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -