Now that we’re in the plotting environment, let’s install numpy, scipy, and matplotlib : $ pip install numpyĪwesome - all of our Python dependencies are installed. Since we are using matplotlib, let’s create a new virtual environment called plotting : $ mkvirtualenv plotting And our goal is to take the following image (left) and compute a grayscale pixel intensity histogram for it using matplotlib (right):įigure 1: Our end goal is to utilize matplotlib to display a grayscale pixel intensity for the image on the left. We’re (optionally) utilizing Python virtual environments via virtualenv and virtualenvwrapper.We’re using a Debian based operating system such as Ubuntu or Raspbian.Matplotlib is a heavily used package in the Python scientific community and I hope that this article helps other readers resolve this strange and hard to pinpoint issue. While this post is not exactly related to computer vision or OpenCV, I still want to share my experience and solution with other PyImageSearch readers. Luckily, after a lot of trial and error (and spending an entire day trying to come up with a solution), I have been able to resolve the problem and get matplotlib figures to show up and display on my screen on both the Ubuntu and Raspbian operating systems (and when using Python virtual environments). The issue actually stems from the matplotlib backend not being properly set, or from a missing dependency when compiling and installing matplotlib. This issue is only further compounded when utilizing virtual environments via the virtualenv and virtualenvwrapper packages. This is actually a common problem I’ve ran into over the past few months, especially when working with Debian based operating systems such as Ubuntu and Raspbian. I coded up a quick Python script using matplotlib, executed the script, only to not have the figure displayed to my screen. Over the weekend I was playing around with deep learning on my Ubuntu system and went to plot the accuracy scores of my classifier. I think a better title for this blog post might be: How I lost a day of productivity to Ubuntu, virtual environments, matplotlib, and rendering backends. Click here to download the source code to this post
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |