You have imported plot() from Matplotlib, not from igraph. You need to import igraph's plot() function:
>>> from igraph import plot >>> plot(dd).show() T. On Sun, Sep 18, 2016 at 10:15 AM, 四正(红砖) <[email protected]> wrote: > > Thank you for your reply, Tamas. But when I use plot(dd), I got a type > error: > > BTW, i'm using python 3.5.1 > > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > <ipython-input-6-40f2a8de40be> in <module>() > 1 dd = g.degree_distribution() > ----> 2 plot(dd).show() > > /usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py in plot(*args, > **kwargs) > 3152 ax.hold(hold) > 3153 try: > -> 3154 ret = ax.plot(*args, **kwargs) > 3155 finally: > 3156 ax.hold(washold) > > /usr/local/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, > *args, **kwargs) > 1809 warnings.warn(msg % (label_namer, > func.__name__), > 1810 RuntimeWarning, stacklevel=2) > -> 1811 return func(ax, *args, **kwargs) > 1812 pre_doc = inner.__doc__ > 1813 if pre_doc is None: > > /usr/local/lib/python3.5/site-packages/matplotlib/axes/_axes.py in > plot(self, *args, **kwargs) > 1426 > 1427 for line in self._get_lines(*args, **kwargs): > -> 1428 self.add_line(line) > 1429 lines.append(line) > 1430 > > /usr/local/lib/python3.5/site-packages/matplotlib/axes/_base.py in > add_line(self, line) > 1697 line.set_clip_path(self.patch) > 1698 > -> 1699 self._update_line_limits(line) > 1700 if not line.get_label(): > 1701 line.set_label('_line%d' % len(self.lines)) > > /usr/local/lib/python3.5/site-packages/matplotlib/axes/_base.py in > _update_line_limits(self, line) > 1708 Figures out the data limit of the given line, updating > self.dataLim. > 1709 """ > -> 1710 path = line.get_path() > 1711 if path.vertices.size == 0: > 1712 return > > /usr/local/lib/python3.5/site-packages/matplotlib/lines.py in get_path(self) > 924 """ > 925 if self._invalidy or self._invalidx: > --> 926 self.recache() > 927 return self._path > 928 > > /usr/local/lib/python3.5/site-packages/matplotlib/lines.py in recache(self, > always) > 618 y = ma.asarray(yconv, np.float_).filled(np.nan) > 619 else: > --> 620 y = np.asarray(yconv, np.float_) > 621 y = y.ravel() > 622 else: > > /usr/local/lib/python3.5/site-packages/numpy/core/numeric.py in asarray(a, > dtype, order) > 472 > 473 """ > --> 474 return array(a, dtype, copy=False, order=order) > 475 > 476 def asanyarray(a, dtype=None, order=None): > > TypeError: float() argument must be a string or a number, not 'Histogram' > > > ------------------ Original ------------------ > From: "Tamas Nepusz";<[email protected]>; > Date: Sun, Sep 18, 2016 03:45 AM > To: "Help for igraph users"<[email protected]>; > Subject: Re: [igraph] how to plot degree distribution, please? > >> dd = g.degree_distribution() >> dd.__plot__("dd",(800,800),None) > > __plot__ is an internal function; you are not supposed to call it > directly. Call the plot() function instead: > >>>> dd = g.degree_distribution() >>>> plot(dd) > > or, if the plot is not shown automatically, then: > >>>> plot(dd).show() > > T. > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
