plt13_image.py 992 B

1234567891011121314151617181920212223242526272829303132
  1. # View more python tutorials on my Youtube and Youku channel!!!
  2. # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
  3. # Youku video tutorial: http://i.youku.com/pythontutorial
  4. # 13 - image
  5. """
  6. Please note, this script is for python3+.
  7. If you are using python2+, please modify it accordingly.
  8. """
  9. import matplotlib.pyplot as plt
  10. import numpy as np
  11. # image data
  12. a = np.array([0.313660827978, 0.365348418405, 0.423733120134,
  13. 0.365348418405, 0.439599930621, 0.525083754405,
  14. 0.423733120134, 0.525083754405, 0.651536351379]).reshape(3,3)
  15. """
  16. for the value of "interpolation", check this:
  17. http://matplotlib.org/examples/images_contours_and_fields/interpolation_methods.html
  18. for the value of "origin"= ['upper', 'lower'], check this:
  19. http://matplotlib.org/examples/pylab_examples/image_origin.html
  20. """
  21. plt.imshow(a, interpolation='nearest', cmap='bone', origin='lower')
  22. plt.colorbar(shrink=.92)
  23. plt.xticks(())
  24. plt.yticks(())
  25. plt.show()