Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No errors but also no display.. #5

Closed
cgoliver opened this issue Jan 13, 2017 · 18 comments
Closed

No errors but also no display.. #5

cgoliver opened this issue Jan 13, 2017 · 18 comments

Comments

@cgoliver
Copy link

Hello,

Thanks for sharing this tool.

I am running on MacOS 10.2 Sierra with anaconda python 3.5.
I also have XQuartz installed.

I set the environment variables correctly and have the latest version of the script.

When I try to run test.py or a simple plot in ipython, i just get a blank space and no display.

I was wondering if you have any suggestions

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

In [3]: plt.show()


In [4]: 

Thanks!

@daleroberts
Copy link
Owner

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()

@cgoliver
Copy link
Author

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.

@daleroberts
Copy link
Owner

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

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

@daleroberts
Copy link
Owner

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.

@cgoliver
Copy link
Author

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>.

@daleroberts
Copy link
Owner

daleroberts commented Jan 13, 2017 via email

@cgoliver
Copy link
Author

no worries, take your time. thanks again!

@daleroberts
Copy link
Owner

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

@cgoliver
Copy link
Author

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!

@daleroberts
Copy link
Owner

daleroberts commented Jan 16, 2017 via email

@cgoliver
Copy link
Author

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]: 

@daleroberts
Copy link
Owner

daleroberts commented Jan 17, 2017 via email

@cgoliver
Copy link
Author

same error :(

@daleroberts
Copy link
Owner

daleroberts commented Jan 17, 2017 via email

@cgoliver
Copy link
Author

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()

@daleroberts
Copy link
Owner

daleroberts commented Jan 17, 2017 via email

@cgoliver
Copy link
Author

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()
[]
>>> 

@daleroberts
Copy link
Owner

daleroberts commented Jan 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants