2017-11-15 31 views
0

でグラフmatplotlibをプロットできません。新しいノートパソコンを使用して、古いデータを新しいノートに転送します。しかし、私のmatplotlibは、新しいウィンドウにグラフをプロットしたくないが、それは古いもので動作する。私はmatplotlibの、すべてと間違っjupyterノートブック

import numpy as np 
import matplotlib.pyplot as pl 

#creating list 
pd = {0.05, 0.34, 0.56, 0.5, 0.7,0.2, 0.36, 0.54, 0.65, 0.456} 
#len of the lists 
d = len (pd) 
print (d) 

x = range(d) 
bwidth= 1/1.25 
pl.figure(1,figsize =(7,5)) 
pl.bar(x,pd,bwidth, color = "red") 
pl.show() 

何が起こっているか全く分からないのインストールを確認しており、これは私がmatplotlibの2.1.0バージョンとPython 3.6.3を使用して

TypeError         Traceback (most recent call last) 
<ipython-input-12-b7b3df1db861> in <module>() 
    12 bwidth= 1/1.25 
    13 pl.figure(1,figsize =(7,5)) 
---> 14 pl.bar(x,pd,bwidth, color = "red") 
    15 pl.show() 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in 
bar(*args, **kwargs) 
2625      mplDeprecation) 
2626  try: 
->2627   ret = ax.bar(*args, **kwargs) 
2628  finally: 
2629   ax._hold = washold 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in 
inner(ax, *args, **kwargs) 
    1708      warnings.warn(msg % (label_namer, func.__name__), 
    1709         RuntimeWarning, stacklevel=2) 
->1710    return func(ax, *args, **kwargs) 
    1711   pre_doc = inner.__doc__ 
    1712   if pre_doc is None: 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in 
bar(self, *args, **kwargs) 
    2154    elif orientation == 'horizontal': 
    2155     r.sticky_edges.x.append(l) 
-> 2156    self.add_patch(r) 
    2157    patches.append(r) 
    2158 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in 
add_patch(self, p) 
    1832   if p.get_clip_path() is None: 
    1833    p.set_clip_path(self.patch) 
-> 1834   self._update_patch_limits(p) 
    1835   self.patches.append(p) 
    1836   p._remove_method = lambda h: self.patches.remove(h) 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in 
_update_patch_limits(self, patch) 
    1852   vertices = patch.get_path().vertices 
    1853   if vertices.size > 0: 
-> 1854    xys = patch.get_patch_transform().transform(vertices) 
    1855    if patch.get_data_transform() != self.transData: 
    1856     patch_to_data = (patch.get_data_transform() - 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\patches.py in 
get_patch_transform(self) 
    720 
    721  def get_patch_transform(self): 
--> 722   self._update_patch_transform() 
    723   return self._rect_transform 
    724 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\patches.py in 
_update_patch_transform(self) 
    713   width = self.convert_xunits(self._width) 
    714   height = self.convert_yunits(self._height) 
--> 715   bbox = transforms.Bbox.from_bounds(x, y, width, height) 
    716   rot_trans = transforms.Affine2D() 
    717   rot_trans.rotate_deg_around(x, y, self.angle) 

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\transforms.py in 
from_bounds(x0, y0, width, height) 
    802   *width* and *height* may be negative. 
    803   """ 
--> 804   return Bbox.from_extents(x0, y0, x0 + width, y0 + height) 
    805 
    806  @staticmethod 

TypeError: unsupported operand type(s) for +: 'int' and 'set' 

イムを得た誤りであります

答えて

0

セットをプロットすることはできません。上のコードではpdはリストではなくセットです。あなたが最初にプロットする前にリストに変換することができます

plt.bar(x, list(pd), bwidth, color = "red") 
関連する問題