Ben,
That worked great, thanks!!! Just a few points. The documentation under
the image tutorial section does not specify that a user has to do
"plt.show()", should I submit a bug report or something? I changed my code
and listed it below it works as long as I comment out the plot c section.
In other words if I perform a normal 2d plot then close plot window the
image plot does not product a result. If I comment out the plot c section
then the image plot works great. Any ideas?
Even the stink bug example is working when I read a image from disk.
Thanks.
# -*- coding: utf-8 -*-
from numpy import *
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
print "Numpy version: " + __version__
a = array([10,20,30,40])
print "result of a"
print a
b = arange(4)
print "result of b"
print b
c = linspace(-pi, pi, 30)
print "result of c"
print c
# this plot code works
print "plot c"
plt.plot(c)
plt.ylabel("-pi to + pi")
plt.xlabel("value of c")
plt.show()
# this image processing code does not work
print "doing image processing stuff"
img=mpimg.imread("/Users/rovitotv/Desktop/stinkbug.png") # this does not
work
##img = zeros((10, 10), dtype=uint8)
##for i in range(10):
## img[i,i] = 255;
plt.imshow(img)
plt.show()
print "data type of img:"
print img.dtype
print "size of img:" + str(img.size)
print img
On Mon, Jun 7, 2010 at 10:04 AM, Benjamin Root <ben.r...@ou.edu> wrote:
> Todd,
>
> I think you are missing a "plt.show()" at the end of your code.
> matplotlib, by default on most systems, does not show a plot until you tell
> it to using plt.show() command.
>
> See if that works,
> Ben Root
>
> On Mon, Jun 7, 2010 at 7:57 AM, Todd V Rovito <rovit...@gmail.com>wrote:
>
>> Greetings,
>> I just installed Python 2.6 (python.org), Numpy 1.4.1, and Matplotlib
>> 0.99.1.2 all on Mac OS X 10.6 in an attempt to learn about scientific
>> programming in python. Go easy on me since I am a begginer. The Python and
>> Numpy seem to be working correctly. I can get matplotlib to make plots but
>> I can't get it to show images. I tried the stinkbug example in
>> the Matplotlib users guide documentation with no success. Errors are _NOT_
>> generated but neither are any results on the screen. The imread command
>> produces a float32 matrix that contains all 1. values so I tried creating my
>> own uint8 matrix with a diagnoal line. My code is below. Thanks for any
>> help you can provide.
>>
>>
>>
>> # -*- coding: utf-8 -*-
>> from numpy import *
>> import matplotlib.pyplot as plt
>> import matplotlib.image as mpimg
>>
>> print "Numpy version: " + __version__
>> a = array([10,20,30,40])
>> print "result of a"
>> print a
>>
>> b = arange(4)
>> print "result of b"
>> print b
>>
>> c = linspace(-pi, pi, 30)
>> print "result of c"
>> print c
>>
>> # this plot code works
>> print "plot c"
>> plt.plot(c)
>> plt.ylabel("-pi to + pi")
>> plt.xlabel("value of c")
>> plt.show()
>>
>> # this image processing code does not work
>> print "doing image processing stuff"
>> # img=mpimg.imread("/Users/rovitotv/Desktop/stinkbug.png") # this does not
>> work
>> img = zeros((10, 10), dtype=uint8)
>> for i in range(10):
>> img[i,i] = 255;
>>
>> plt.imshow(img)
>> print "data type of img:"
>> print img.dtype
>> print "size of img:" + str(img.size)
>> print img
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>> lucky parental unit. See the prize list and enter to win:
>> http://p.sf.net/sfu/thinkgeek-promo
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit. See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users