Giter Club home page Giter Club logo

Comments (18)

daleroberts avatar daleroberts commented on May 18, 2024

Perhaps ipython has already set the backend to use? I think can happen, for example, if you run %pylab.

What does the ipython start-up message say in regards to the backend?

Does this script work if you run it from the command line?

import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12) 
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: %pylab
Using matplotlib backend: MacOSX
Populating the interactive namespace from numpy and matplotlib

In [2]: plt.plot([1, 2, 3])
Out[2]: [<matplotlib.lines.Line2D at 0x110c87dd8>]

If I run from the command line, also nothing happens. So it appears it's not using the iterm backend.

However in my ~/.bash_profile I have the following lines:

export PYTHONPATH=~/itermplot:$PYTHONPATH
export MPLBACKEND="module://itermplot"
export ITERMPLOT="rv"

And I have the itermplot/ directory in ~/

So I guess this is not successfully setting the backend?

Thanks for the help.

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

Yeah, the problem is the line: Using matplotlib backend: MacOSX.

Don't use %pylab and try pasting the above test script in ipython directly.

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

Btw, I've updated the installation instructions to use a setup.py and pip. This means you no longer have to set PYTHONPATH as it will put it in your site-packages directory.

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

Ok, I am trying to install with pip now but it seems to not be able to find the module..

(py35) carlosgonzalezoliver@sasja-air: ~> pip install git+https://github.com/daleroberts/itermplot.git
Collecting git+https://github.com/daleroberts/itermplot.git
  Cloning https://github.com/daleroberts/itermplot.git to /private/var/folders/nm/q6jm6_sj1kj7ff1_vpz2r7740000gn/T/pip-nvwaj35l-build
  Requirement already satisfied (use --upgrade to upgrade): itermplot==0.1 from git+https://github.com/daleroberts/itermplot.git in ./anaconda/envs/py35/lib/python3.5/site-packages
(py35) carlosgonzalezoliver@sasja-air: ~> python 
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12) 
Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import itermplot
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-4f66c2c10566> in <module>()
----> 1 import itermplot

ImportError: No module named 'itermplot'

In [2]: 

However, when I do conda list I see itermplot 0.1 <pip>.

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

no worries, take your time. thanks again!

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

Hopefully this should all be fixed now @cgoliver. Try pip3 install -U itermplot

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

Hi! So I tried that and i'm still getting the same issue of nothing being displayed. Let me know if you want more info on my setup or if you have any more suggestions. Thanks!

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

hello! just tried that and now I get this error lol..

In [1]: import matplotlib.pyplot as plt
/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/font_manager.py:280: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  'Matplotlib is building the font cache using fc-list. '

In [2]: plt.plot([1, 2, 3])
Out[2]: [<matplotlib.lines.Line2D at 0x105ec7748>]

In [3]: plt.show()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-3-c4e69632d98a> in <module>()
----> 1 plt.show()

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/pyplot.py in show(*args, **kw)
    251     """
    252     global _show
--> 253     return _show(*args, **kw)
    254 
    255 

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in show()
    116     figmanager = Gcf.get_active()
    117     if figmanager is not None:
--> 118         figmanager.show()
    119     else:
    120         for manager in Gcf.get_all_fig_managers():

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in show(self)
    208         data = io.BytesIO()
    209         self.canvas.print_figure(data, facecolor='none',
--> 210                                  edgecolor='none', transparent=True)
    211         if hasattr(data, 'getbuffer'):
    212             imgcat(data.getbuffer())

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2242                 orientation=orientation,
   2243                 bbox_inches_restore=_bbox_inches_restore,
-> 2244                 **kwargs)
   2245         finally:
   2246             if bbox_inches and restore_bbox:

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in print_pdf(self, filename, **kwargs)
    195 
    196         if 'rv' in os.getenv('ITERMPLOT', ''):
--> 197             self.reverse()
    198 
    199         FigureCanvasPdf.print_pdf(self, filename, **kwargs)

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in reverse(self, **kwargs)
    170         for obj in self.figure.findobj():
    171             if not obj in seen:
--> 172                 modify(obj)
    173             seen.add(obj)
    174 

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in modify(c)
    163                 if not fcset:
    164                     c = obj.get_color()
--> 165                     obj.set_color(revvideo(c))
    166             except AttributeError as e:
    167                 pass

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in revvideo(x)
     61             return np.array([rev(el) for el in x])
     62         else:
---> 63             return rev(x)
     64 
     65     except ValueError:

/Users/carlosgonzalezoliver/anaconda/envs/py35/lib/python3.5/site-packages/itermplot/__init__.py in rev(c)
     46     def rev(c):
     47         if isinstance(c, str):
---> 48             c = COLORS[c]
     49 
     50         if len(c) == 4:

KeyError: '#1f77b4'

In [4]: 

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

same error :(

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

hi! yep i did that and I even made a fresh environment with anaconda to make sure I wasn't changing something or some other module was changing something.

$ conda create --name fresh python=3.5
$ source activate fresh
$ pip install -U itermplot

Running interactively or from script yields the same error. Here is the script:

 import matplotlib.pyplot as plt
  
  plt.plot([1, 2, 3])
  plt.show()

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

from itermplot.

cgoliver avatar cgoliver commented on May 18, 2024

hmm okay i'll look into it

in the meantime I ran with non-anaconda python

carlosgonzalezoliver@wpa167102: Figures> /usr/local/Cellar/python3/3.6.0/bin/python3
Python 3.6.0 (default, Dec 24 2016, 08:01:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import itermplot
>>> import matplotlib.pyplot as plt
>>> plt.plot([1, 2, 3])
[<matplotlib.lines.Line2D object at 0x1103b1f98>]
>>> plt.plot()
[]
>>> 

from itermplot.

daleroberts avatar daleroberts commented on May 18, 2024

from itermplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.