Skip to content

Commit

Permalink
Changed add_grayscale_image_to_plot test to use matplotlib's imread f…
Browse files Browse the repository at this point in the history
…unction because scipy's imread is deprecated. Also eliminated the comment about matplotlib/matplotlib#4260 since it appears to be resolved.
  • Loading branch information
Benjamin committed Oct 20, 2020
1 parent 7395bc8 commit f6da387
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Binary file not shown.
12 changes: 4 additions & 8 deletions tests/add_grayscale_image_to_plot/add_grayscale_image_to_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@

import clearplot.figure as cpfig
import clearplot as cp
import os, scipy.misc
import os
import matplotlib.pyplot
data_dir = os.path.join(os.path.dirname(os.path.dirname(cp.__file__)), \
'doc', 'source', 'data')

#Verification of adding an image and adding a color bar
#Load image data
path = os.path.join(data_dir, 'fiber_image.tiff')
im = scipy.misc.imread(path)
im = matplotlib.pyplot.imread(path)
fig = cpfig.Figure()
ax = fig.add_axes()
ax.x_label = ['x', 'pix']
ax.y_label = ['y', 'pix']
im_obj = ax.add_image(im, im_interp = 'bilinear', c_map = cp.colors.c_maps['light_gray'])
ax.x_tick = 50
fig.add_color_bar(im_obj)
fig.auto_adjust_layout()
#As reported in issue #4260 on Github
#(https://github.com/matplotlib/matplotlib/issues/4260) matplotlib makes the
#axes background black when saving pdfs, with 1 image, grayscale colormaps, and
#transparent background. So we avoid this by making the background opaque.
fig.save('add_grayscale_image_to_plot', transparent = False)
fig.auto_adjust_layout()

0 comments on commit f6da387

Please sign in to comment.