Error in getting network figure in python networkx - python

I'm running this code to get a network figure. I'm using networkx package in python.
from pylab import rcParams
rcParams['figure.figsize'] = 14, 10
pos = nx.spring_layout(g, scale=20, k=3/np.sqrt(g.order()))
d = dict(g.degree)
plt.figure(figsize=(10, 9))
nx.draw(g, pos, node_color='green',
with_labels=True,
nodelist=d,
node_size=[d[k]*200 for k in d])
But getting the following error. This code runs fine in Kaggle or Colab but problem occurs when I try to run this segment in jupyter Notebook of my computer.
IndexError Traceback (most recent call last)
~\anaconda3\lib\site-packages\networkx\utils\decorators.py in _random_state(func, *args, **kwargs)
395 try:
--> 396 random_state_arg = args[random_state_index]
397 except TypeError as e:
IndexError: tuple index out of range
The above exception was the direct cause of the following exception:
NetworkXError Traceback (most recent call last)
<ipython-input-18-83602777a5ba> in <module>
1 from pylab import rcParams
2 rcParams['figure.figsize'] = 14, 10
----> 3 pos = nx.spring_layout(g, scale=20, k=3/np.sqrt(g.order()))
4 d = dict(g.degree)
5 plt.figure(figsize=(10, 9))
~\anaconda3\lib\site-packages\decorator.py in fun(*args, **kw)
229 if not kwsyntax:
230 args, kw = fix(args, kw, sig)
--> 231 return caller(func, *(extras + args), **kw)
232 fun.__name__ = func.__name__
233 fun.__doc__ = func.__doc__
~\anaconda3\lib\site-packages\networkx\utils\decorators.py in _random_state(func, *args, **kwargs)
398 raise nx.NetworkXError("random_state_index must be an integer") from e
399 except IndexError as e:
--> 400 raise nx.NetworkXError("random_state_index is incorrect") from e
401
402 # Create a numpy.random.RandomState instance
NetworkXError: random_state_index is incorrect
Any solution anyone?

Related

Error when importing seaborn in Jupyter notebook

When I try to import seaborn I get the following error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/opt/conda/anaconda/lib/python3.7/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
800 try:
--> 801 cval = self.validate[key](val)
802 except ValueError as ve:
KeyError: 'axes.color_cycle'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-1-334c7a663000> in <module>
1 import matplotlib.pyplot as plt
----> 2 import seaborn as sns
3 import pandas as pd
4 import nbashots as nba # this will throw a warning if using matplotlib 1.5
5
/opt/conda/anaconda/lib/python3.7/site-packages/seaborn/__init__.py in <module>
11 from .xkcd_rgb import xkcd_rgb
12 from .crayons import crayons
---> 13 set()
14
15 __version__ = "0.6.0"
/opt/conda/anaconda/lib/python3.7/site-packages/seaborn/rcmod.py in set(context, style, palette, font, font_scale, color_codes, rc)
96 set_context(context, font_scale)
97 set_style(style, rc={"font.family": font})
---> 98 set_palette(palette, color_codes=color_codes)
99 if rc is not None:
100 mpl.rcParams.update(rc)
/opt/conda/anaconda/lib/python3.7/site-packages/seaborn/rcmod.py in set_palette(palette, n_colors, desat, color_codes)
489 """
490 colors = palettes.color_palette(palette, n_colors, desat)
--> 491 mpl.rcParams["axes.color_cycle"] = list(colors)
492 mpl.rcParams["patch.facecolor"] = colors[0]
493 if color_codes:
/opt/conda/anaconda/lib/python3.7/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
805 except KeyError:
806 raise KeyError(
--> 807 f"{key} is not a valid rc parameter (see rcParams.keys() for "
808 f"a list of valid parameters)")
809
KeyError: 'axes.color_cycle is not a valid rc parameter (see rcParams.keys() for a list of valid parameters)'
I'm pretty sure this is because I am using a more recent version of matplotlib and that color_cycle was deprecated in matplotlib 1.5. Any suggestions on how I can fix this issue? I have searched the web for hours but haven't been able to find a solution.

TypeError: plotting not available (Google Colab)

Here is the error I am getting when I am using plot.
imort cairo doesn't give any errors which means the library which igraph uses to plot is installed still it shows up error. Can anyone help me in resolving this issue.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-8ddaf3cef6bc> in <module>()
1 layout = G.layout("kk")
----> 2 plot(G , layout = layout)
2 frames
/usr/local/lib/python3.6/dist-packages/igraph/drawing/__init__.py in plot(obj, target, bbox, *args, **kwds)
444 bbox = BoundingBox(bbox)
445
--> 446 result = Plot(target, bbox, background=kwds.get("background", "white"))
447
448 if "margin" in kwds:
/usr/local/lib/python3.6/dist-packages/igraph/drawing/__init__.py in __init__(self, target, bbox, palette, background)
115 """
116 self._filename = None
--> 117 self._surface_was_created = not isinstance(target, cairo.Surface)
118 self._need_tmpfile = False
119
/usr/local/lib/python3.6/dist-packages/igraph/drawing/utils.py in __getattr__(self, _)
394
395 def __getattr__(self, _):
--> 396 raise TypeError("plotting not available")
397 def __call__(self, _):
398 raise TypeError("plotting not available")
TypeError: plotting not available

How to get add aditional transform to get_transform in fastai?

I would like to add aditional augmenmentation this way:
additional_aug=[zoom_crop(scale=(0.75,1.25), do_rand=False),
brightness(),
contrast()
]
tfms = get_transforms(do_flip=True,flip_vert=True,max_lighting=0.2, xtra_tfms=additional_aug)
data = (ImageList.from_df(df=df,path='./',cols='path')
.split_by_rand_pct(0.2)
.label_from_df(cols='diagnosis',label_cls=FloatList)
.transform(tfms,size=sz,resize_method=ResizeMethod.SQUISH,padding_mode='zeros')
.databunch(bs=bs,num_workers=4)
.normalize(imagenet_stats)
)
But I get errors:
--------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
590 x = ds[0]
--> 591 try: x.apply_tfms(tfms, **kwargs)
592 except Exception as e:
/opt/conda/lib/python3.6/site-packages/fastai/vision/image.py in apply_tfms(self, tfms, do_resolve, xtra, size, resize_method, mult, padding_mode, mode, remove_out)
105 if resize_method <= 2 and size is not None: tfms = self._maybe_add_crop_pad(tfms)
--> 106 tfms = sorted(tfms, key=lambda o: o.tfm.order)
107 if do_resolve: _resolve_tfms(tfms)
/opt/conda/lib/python3.6/site-packages/fastai/vision/image.py in <lambda>(o)
105 if resize_method <= 2 and size is not None: tfms = self._maybe_add_crop_pad(tfms)
--> 106 tfms = sorted(tfms, key=lambda o: o.tfm.order)
107 if do_resolve: _resolve_tfms(tfms)
AttributeError: 'list' object has no attribute 'tfm'
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
<ipython-input-27-3daf86c69a96> in <module>
2 .split_by_rand_pct(0.2)
3 .label_from_df(cols='diagnosis',label_cls=FloatList)
----> 4 .transform(tfms,size=sz,resize_method=ResizeMethod.SQUISH,padding_mode='zeros')
5 .databunch(bs=bs,num_workers=4)
6 .normalize(imagenet_stats)
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in transform(self, tfms, **kwargs)
500 if not tfms: tfms=(None,None)
501 assert is_listy(tfms) and len(tfms) == 2, "Please pass a list of two lists of transforms (train and valid)."
--> 502 self.train.transform(tfms[0], **kwargs)
503 self.valid.transform(tfms[1], **kwargs)
504 if self.test: self.test.transform(tfms[1], **kwargs)
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in transform(self, tfms, tfm_y, **kwargs)
719 def transform(self, tfms:TfmList, tfm_y:bool=None, **kwargs):
720 "Set the `tfms` and `tfm_y` value to be applied to the inputs and targets."
--> 721 _check_kwargs(self.x, tfms, **kwargs)
722 if tfm_y is None: tfm_y = self.tfm_y
723 tfms_y = None if tfms is None else list(filter(lambda t: getattr(t, 'use_on_y', True), listify(tfms)))
/opt/conda/lib/python3.6/site-packages/fastai/data_block.py in _check_kwargs(ds, tfms, **kwargs)
591 try: x.apply_tfms(tfms, **kwargs)
592 except Exception as e:
--> 593 raise Exception(f"It's not possible to apply those transforms to your dataset:\n {e}")
594
595 class LabelList(Dataset):
Exception: It's not possible to apply those transforms to your dataset:
'list' object has no attribute 'tfm'
According to documentation xtra_tfms : Optional [ Collection [ Transform ]]= None ) →  Collection [ Transform ]
How to get it work?
I have faced this problem and the solution is very simple. Just call each transform function that you want to apply each inside a separate list enclosed by a list and pass it into get_transforms function's xtra_tfms parameter. (It could even be a tuple of tuples or any collection)
additional_aug=[[zoom_crop(scale=(0.75,1.25), do_rand=False)],
[brightness()],
[contrast()]]
tfms = get_transforms(do_flip=True,
flip_vert=True,
max_lighting=0.2,
xtra_tfms=additional_aug)
Hope this solves your problem.

pymc3: Disaster example with deterministic switchpoint function

I'm trying to reproduce coal mining example with deterministic function for switchpoint instead of using theano's switch function. Code:
%matplotlib inline
import matplotlib.pyplot as plt
import pymc3
import numpy as np
import theano.tensor as t
import theano
data = np.hstack((np.random.poisson(15,1000),np.random.poisson(2,100)))
plt.plot(data)
#theano.compile.ops.as_op(itypes=[t.lscalar, t.dscalar,t.dscalar],otypes=[t.dvector])
def rate1(sw,mu1,mu2):
n = len(data)
out = np.empty(n)
out[:sw] = mu1
out[sw:] = mu2
return out
with pymc3.Model() as dis:
switchpoint = pymc3.DiscreteUniform('switchpoint',lower=0, upper=len(data)-1)
mu1 = pymc3.Exponential('mu1', lam=1.)
mu2 = pymc3.Exponential('mu2',lam=1.)
disasters=pymc3.Poisson('disasters', mu=rate1, observed = data)
But this code rise an error:
--------------------------------------------------------------------------- KeyError Traceback (most recent call
last) c:\program files\git\theano\theano\tensor\type.py in
dtype_specs(self)
266 'complex64': (complex, 'theano_complex64', 'NPY_COMPLEX64')
--> 267 }[self.dtype]
268 except KeyError:
KeyError: 'object'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call
last) c:\program files\git\theano\theano\tensor\basic.py in
constant_or_value(x, rtype, name, ndim, dtype)
407 rval = rtype(
--> 408 TensorType(dtype=x_.dtype, broadcastable=bcastable),
409 x_.copy(),
c:\program files\git\theano\theano\tensor\type.py in init(self,
dtype, broadcastable, name, sparse_grad)
49 self.broadcastable = tuple(bool(b) for b in broadcastable)
---> 50 self.dtype_specs() # error checking is done there
51 self.name = name
c:\program files\git\theano\theano\tensor\type.py in dtype_specs(self)
269 raise TypeError("Unsupported dtype for %s: %s"
--> 270 % (self.class.name, self.dtype))
271
TypeError: Unsupported dtype for TensorType: object
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call
last) c:\program files\git\theano\theano\tensor\basic.py in
as_tensor_variable(x, name, ndim)
201 try:
--> 202 return constant(x, name=name, ndim=ndim)
203 except TypeError:
c:\program files\git\theano\theano\tensor\basic.py in constant(x,
name, ndim, dtype)
421 ret = constant_or_value(x, rtype=TensorConstant, name=name, ndim=ndim,
--> 422 dtype=dtype)
423
c:\program files\git\theano\theano\tensor\basic.py in
constant_or_value(x, rtype, name, ndim, dtype)
416 except Exception:
--> 417 raise TypeError("Could not convert %s to TensorType" % x, type(x))
418
TypeError: ('Could not convert FromFunctionOp{rate1} to TensorType',
)
During handling of the above exception, another exception occurred:
AsTensorError Traceback (most recent call
last) in ()
14 mu2 = pymc3.Exponential('mu2',lam=1.)
15 #rate1 = pymc3.switch(switchpoint >= np.arange(len(data)), mu1,mu2)
---> 16 disasters=pymc3.Poisson('disasters', mu=rate1, observed = data)
C:\Users\User\Anaconda3\lib\site-packages\pymc3\distributions\distribution.py
in new(cls, name, *args, **kwargs)
19 if isinstance(name, str):
20 data = kwargs.pop('observed', None)
---> 21 dist = cls.dist(*args, **kwargs)
22 return model.Var(name, dist, data)
23 elif name is None:
C:\Users\User\Anaconda3\lib\site-packages\pymc3\distributions\distribution.py
in dist(cls, *args, **kwargs)
32 def dist(cls, *args, **kwargs):
33 dist = object.new(cls)
---> 34 dist.init(*args, **kwargs)
35 return dist
36
C:\Users\User\Anaconda3\lib\site-packages\pymc3\distributions\discrete.py
in init(self, mu, *args, **kwargs)
185 super(Poisson, self).init(*args, **kwargs)
186 self.mu = mu
--> 187 self.mode = floor(mu).astype('int32')
188
189 def random(self, point=None, size=None, repeat=None):
c:\program files\git\theano\theano\gof\op.py in call(self,
*inputs, **kwargs)
598 """
599 return_list = kwargs.pop('return_list', False)
--> 600 node = self.make_node(*inputs, **kwargs)
601
602 if config.compute_test_value != 'off':
c:\program files\git\theano\theano\tensor\elemwise.py in
make_node(self, *inputs)
540 using DimShuffle.
541 """
--> 542 inputs = list(map(as_tensor_variable, inputs))
543 shadow = self.scalar_op.make_node(
544 *[get_scalar_type(dtype=i.type.dtype).make_variable()
c:\program files\git\theano\theano\tensor\basic.py in
as_tensor_variable(x, name, ndim)
206 except Exception:
207 str_x = repr(x)
--> 208 raise AsTensorError("Cannot convert %s to TensorType" % str_x, type(x))
209
210 # this has a different name, because _as_tensor_variable is the
AsTensorError: ('Cannot convert FromFunctionOp{rate1} to TensorType',
)
How i handle this?
The second thing - when i'm using the pymc3.switch function like this:
with pymc3.Model() as dis:
switchpoint = pymc3.DiscreteUniform('switchpoint',lower=0, upper=len(data)-1)
mu1 = pymc3.Exponential('mu1', lam=1.)
mu2 = pymc3.Exponential('mu2',lam=1.)
rate1 = pymc3.switch(switchpoint >= np.arange(len(data)), mu1,mu2)
disasters=pymc3.Poisson('disasters', mu=rate1, observed = data)
And next try to sample:
with dis:
step1 = pymc3.NUTS([mu1, mu2])
step2 = pymc3.Metropolis([switchpoint])
trace = pymc3.sample(10000, step = [step1,step2])
I get an error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
c:\program files\git\theano\theano\compile\function_module.py in __call__(self, *args, **kwargs)
858 try:
--> 859 outputs = self.fn()
860 except Exception:
TypeError: expected type_num 9 (NPY_INT64) got 7
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-4-3247d908f897> in <module>()
2 step1 = pymc3.NUTS([mu1, mu2])
3 step2 = pymc3.Metropolis([switchpoint])
----> 4 trace = pymc3.sample(10000, step = [step1,step2])
C:\Users\User\Anaconda3\lib\site-packages\pymc3\sampling.py in sample(draws, step, start, trace, chain, njobs, tune, progressbar, model, random_seed)
153 sample_args = [draws, step, start, trace, chain,
154 tune, progressbar, model, random_seed]
--> 155 return sample_func(*sample_args)
156
157
C:\Users\User\Anaconda3\lib\site-packages\pymc3\sampling.py in _sample(draws, step, start, trace, chain, tune, progressbar, model, random_seed)
162 progress = progress_bar(draws)
163 try:
--> 164 for i, strace in enumerate(sampling):
165 if progressbar:
166 progress.update(i)
C:\Users\User\Anaconda3\lib\site-packages\pymc3\sampling.py in _iter_sample(draws, step, start, trace, chain, tune, model, random_seed)
244 if i == tune:
245 step = stop_tuning(step)
--> 246 point = step.step(point)
247 strace.record(point)
248 yield strace
C:\Users\User\Anaconda3\lib\site-packages\pymc3\step_methods\compound.py in step(self, point)
11 def step(self, point):
12 for method in self.methods:
---> 13 point = method.step(point)
14 return point
C:\Users\User\Anaconda3\lib\site-packages\pymc3\step_methods\arraystep.py in step(self, point)
116 bij = DictToArrayBijection(self.ordering, point)
117
--> 118 apoint = self.astep(bij.map(point))
119 return bij.rmap(apoint)
120
C:\Users\User\Anaconda3\lib\site-packages\pymc3\step_methods\metropolis.py in astep(self, q0)
123
124
--> 125 q_new = metrop_select(self.delta_logp(q,q0), q, q0)
126
127 if q_new is q:
c:\program files\git\theano\theano\compile\function_module.py in __call__(self, *args, **kwargs)
869 node=self.fn.nodes[self.fn.position_of_error],
870 thunk=thunk,
--> 871 storage_map=getattr(self.fn, 'storage_map', None))
872 else:
873 # old-style linkers raise their own exceptions
c:\program files\git\theano\theano\gof\link.py in raise_with_op(node, thunk, exc_info, storage_map)
312 # extra long error message in that case.
313 pass
--> 314 reraise(exc_type, exc_value, exc_trace)
315
316
C:\Users\User\Anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)
656 value = tp()
657 if value.__traceback__ is not tb:
--> 658 raise value.with_traceback(tb)
659 raise value
660
c:\program files\git\theano\theano\compile\function_module.py in __call__(self, *args, **kwargs)
857 t0_fn = time.time()
858 try:
--> 859 outputs = self.fn()
860 except Exception:
861 if hasattr(self.fn, 'position_of_error'):
TypeError: expected type_num 9 (NPY_INT64) got 7
Apply node that caused the error: Elemwise{Composite{Switch(GE(i0, i1), i2, i3)}}(InplaceDimShuffle{x}.0, TensorConstant{[ 0 1..1098 1099]}, InplaceDimShuffle{x}.0, InplaceDimShuffle{x}.0)
Toposort index: 11
Inputs types: [TensorType(int64, (True,)), TensorType(int32, vector), TensorType(float64, (True,)), TensorType(float64, (True,))]
Inputs shapes: [(1,), (1100,), (1,), (1,)]
Inputs strides: [(4,), (4,), (8,), (8,)]
Inputs values: [array([549]), 'not shown', array([ 1.07762995]), array([ 1.01502801])]
Outputs clients: [[Elemwise{eq,no_inplace}(Elemwise{Composite{Switch(GE(i0, i1), i2, i3)}}.0, TensorConstant{(1,) of 0}), Elemwise{Composite{Switch(GE(i0, i1), ((Switch(i2, i3, (i4 * log(i0))) - i5) - i0), i3)}}[(0, 0)](Elemwise{Composite{Switch(GE(i0, i1), i2, i3)}}.0, TensorConstant{(1,) of 0}, InplaceDimShuffle{x}.0, TensorConstant{(1,) of -inf}, TensorConstant{[ 13. 13... 0. 1.]}, TensorConstant{[ 22.55216... ]})]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'.
HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.
Being simple analyst, should i learn all this stuff about theano to being able to work with my statistical problems? Is a new mcmc sampler with gradient feature is only one thing that should motivates me to switch from pymc2 to pymc3?
For your first question, it looks like you're trying to pass a theano function as a variable. You need to call the function with the other variables as arguments, which will then return a theano variable. Try changing your line to
disasters=pymc3.Poisson('disasters', mu=rate1(switchpoint, mu1, mu2), observed = data)
I couldn't reproduce the error in your second part; the sampling worked just fine for me.

Sympy, plotting geometric entities yields either ImportError: no module named 'plot' or AttributeError: 'Circle' object has no attribute 'is_3D'

Setup: Using Python 3.4.1 from the Anaconda 2.1.0 64-bit installer for Windows 8.1
Using IPython 2.2.0 console
As usual with the Anaconda installer, I have matplotlib 1.4.0 that comes with it.
And I updated from the default sympy on Anaconda to sympy 0.7.6
Problem: I am trying to plot geometric entities as discussed in the sympy documentation http://docs.sympy.org/latest/modules/plotting.html#plot-geom in at least three ways, all yielding errors.
First try using the 'older' PygletPlot, the module being used in the above reference documentation:
In [1]: from sympy.plotting.pygletplot import PygletPlot as Plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: p = Plot(axes='label_axes=True')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-34da7d3c112c> in <module>()
----> 1 p = Plot(axes='label_axes=True')
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
In [5]: Plot(c1)
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-4edba1117b3a> in <module>()
----> 1 Plot(c1)
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
In [6]: p = Plot()
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-f2ff2ed54331> in <module>()
----> 1 p = Plot()
C:\Anaconda3\lib\site-packages\sympy\plotting\pygletplot\__init__.py in PygletPlot(*args, **kwargs)
137 """
138
--> 139 import plot
140 return plot.PygletPlot(*args, **kwargs)
141
ImportError: No module named 'plot'
Second try using the 'newer' plotting module, which keeps being recommended in answers for most plotting problems with sympy:
In [1]: from sympy.plotting.plot import Plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: p = Plot(c1)
In [5]: p.show()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-709f73884a30> in <module>()
----> 1 p.show()
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in show(self)
182 if hasattr(self, '_backend'):
183 self._backend.close()
--> 184 self._backend = self.backend(self)
185 self._backend.show()
186
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in __new__(cls, parent)
1054 matplotlib = import_module('matplotlib', min_module_version='1.1.0', catch=(RuntimeError,))
1055 if matplotlib:
-> 1056 return MatplotlibBackend(parent)
1057 else:
1058 return TextBackend(parent)
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in __init__(self, parent)
861 def __init__(self, parent):
862 super(MatplotlibBackend, self).__init__(parent)
--> 863 are_3D = [s.is_3D for s in self.parent._series]
864 self.matplotlib = import_module('matplotlib',
865 __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']},
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in <listcomp>(.0)
861 def __init__(self, parent):
862 super(MatplotlibBackend, self).__init__(parent)
--> 863 are_3D = [s.is_3D for s in self.parent._series]
864 self.matplotlib = import_module('matplotlib',
865 __import__kwargs={'fromlist': ['pyplot', 'cm', 'collections']},
AttributeError: 'Circle' object has no attribute 'is_3D'
In [6]: Plot(c1)
Out[6]: <sympy.plotting.plot.Plot at 0x6f74ac8>
Third try using the plot() function which the sympy documentation recommends for interactive work:
In [1]: from sympy import plot
In [2]: from sympy import Point, Circle
In [3]: c1 = Circle(Point(1, 0), 3)
In [4]: plot(c1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-685b4d90c5ac> in <module>()
----> 1 plot(c1)
C:\Anaconda3\lib\site-packages\sympy\plotting\plot.py in plot(*args, **kwargs)
1274 series = []
1275 plot_expr = check_arguments(args, 1, 1)
-> 1276 series = [LineOver1DRangeSeries(*arg, **kwargs) for arg in plot_expr]
1277
1278 plots = Plot(*series, **kwargs)
TypeError: 'NoneType' object is not iterable
Thanks for your attention. This is my first time writing a question so I hope I have provided enough information.

Categories