Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b357367

Browse files
committed
Changed the rcParam option name from 'vector_graphics.combine_images' to 'image.combine_images', and updated the matplotlibrc.template.
Update the backend tests with the new rcParam name 'image.combine_images' Added the rcParams 'pdf.combine_images', 'svg.combine_images', and 'ps.combine_images' to permit users to decide whether they want the vector graphics backend to combine all images within a set of axes into a single image. (If images do not get combined, users can open vector graphics files in Adobe Illustrator or Inkscape and edit each image individually.) Also changed 'renderer.option_nocomposite' to the clearer name 'renderer.option_combine_images'. Improved combine image tests to actually count the number of images in the vector graphics files. Also replaced the rcParams 'pdf.combine_images', 'svg.combine_images', and 'ps.combine_images' with 'vector_backends.combine_images' Corrected PEP8 coding standard violations Updated 'combine_images' tests for PS and SVG backends to hopefully make them Python 3 compatible. Fixed some PEP8 violations to leave the code cleaner than I found it. Fixed PEP8 violations introduced in my effort to fix PEP8 violations in my last commit. Changed the rcParam option name from 'vector_graphics.combine_images' to 'image.combine_images', and updated the matplotlibrc.template. Update the backend tests with the new rcParam name 'image.combine_images'
1 parent 7092c9a commit b357367

9 files changed

+18
-13
lines changed

CHANGELOG

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
corner masking. This is controlled by the 'corner_mask' keyword
33
in plotting commands 'contour' and 'contourf'. - IMT
44

5-
2015-01-31 Added the rcParam 'vector_backends.combine_images' to permit users
5+
2015-01-31 Added the rcParam 'image.combine_images' to permit users
66
to decide whether they want the vector graphics backends to combine
77
all images within a set of axes into a single image. (If images do
88
not get combined, users can open vector graphics files in Adobe

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ def option_combine_images(self):
15821582
return whether to combine multiple images on a set of axes into one
15831583
image
15841584
"""
1585-
return rcParams['vector_backends.combine_images']
1585+
return rcParams['image.combine_images']
15861586

15871587
def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
15881588
self.check_gc(gc)

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def option_combine_images(self):
457457
return whether to combine multiple images on a set of axes into one
458458
image
459459
"""
460-
return rcParams['vector_backends.combine_images']
460+
return rcParams['image.combine_images']
461461

462462
def _get_image_h_w_bits_command(self, im):
463463
if im.is_grayscale:

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def option_combine_images(self):
535535
if rcParams['svg.image_noscale']:
536536
return False
537537
else:
538-
return rcParams['vector_backends.combine_images']
538+
return rcParams['image.combine_images']
539539

540540
def _convert_path(self, path, transform=None, clip=None, simplify=None):
541541
if clip:

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ def __call__(self, s):
595595
'image.lut': [256, validate_int], # lookup table
596596
'image.origin': ['upper', six.text_type], # lookup table
597597
'image.resample': [False, validate_bool],
598+
# Force vector graphics backends to combine all images on a set of axes
599+
# into a single image
600+
'image.combine_images': [True, validate_bool],
598601

599602
# contour props
600603
'contour.negative_linestyle': ['dashed',
@@ -764,9 +767,7 @@ def __call__(self, s):
764767
# Maintain shell focus for TkAgg
765768
'tk.window_focus': [False, validate_bool],
766769
'tk.pythoninspect': [False, validate_tkpythoninspect], # obsolete
767-
768-
# combine all images on a set of axes into a single image
769-
'vector_backends.combine_images': [True, validate_bool],
770+
770771
# Set the papersize/type
771772
'ps.papersize': ['letter', validate_ps_papersize],
772773
'ps.useafm': [False, validate_bool], # Set PYTHONINSPECT

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ def test_combine_images():
9999
ax.set_xlim(0, 3)
100100
ax.imshow(Z, extent=[0, 1, 0, 1])
101101
ax.imshow(Z[::-1], extent=[2, 3, 0, 1])
102-
plt.rcParams['vector_backends.combine_images'] = True
102+
plt.rcParams['image.combine_images'] = True
103103
with PdfPages(io.BytesIO()) as pdf:
104104
fig.savefig(pdf, format="pdf")
105105
assert len(pdf._file.images.keys()) == 1
106-
plt.rcParams['vector_backends.combine_images'] = False
106+
plt.rcParams['image.combine_images'] = False
107107
with PdfPages(io.BytesIO()) as pdf:
108108
fig.savefig(pdf, format="pdf")
109109
assert len(pdf._file.images.keys()) == 2

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ def test_combine_images():
9797
ax.set_xlim(0, 3)
9898
ax.imshow(Z, extent=[0, 1, 0, 1])
9999
ax.imshow(Z[::-1], extent=[2, 3, 0, 1])
100-
plt.rcParams['vector_backends.combine_images'] = True
100+
plt.rcParams['image.combine_images'] = True
101101
with io.BytesIO() as ps:
102102
fig.savefig(ps, format="ps")
103103
ps.seek(0)
104104
buff = ps.read()
105105
assert buff.count(six.b(' colorimage')) == 1
106-
plt.rcParams['vector_backends.combine_images'] = False
106+
plt.rcParams['image.combine_images'] = False
107107
with io.BytesIO() as ps:
108108
fig.savefig(ps, format="ps")
109109
ps.seek(0)

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ def test_combine_images():
6666
ax.set_xlim(0, 3)
6767
ax.imshow(Z, extent=[0, 1, 0, 1])
6868
ax.imshow(Z[::-1], extent=[2, 3, 0, 1])
69-
plt.rcParams['vector_backends.combine_images'] = True
69+
plt.rcParams['image.combine_images'] = True
7070
with BytesIO() as svg:
7171
fig.savefig(svg, format="svg")
7272
svg.seek(0)
7373
buff = svg.read()
7474
assert buff.count(six.b('<image ')) == 1
75-
plt.rcParams['vector_backends.combine_images'] = False
75+
plt.rcParams['image.combine_images'] = False
7676
with BytesIO() as svg:
7777
fig.savefig(svg, format="svg")
7878
svg.seek(0)

matplotlibrc.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ backend : %(backend)s
358358
#image.lut : 256 # the size of the colormap lookup table
359359
#image.origin : upper # lower | upper
360360
#image.resample : False
361+
#image.combine_images : True # When True, all the images on a set of axes
362+
# are combined into a single image before
363+
# saving a figure as a vector graphics file,
364+
# such as a PDF.
361365

362366
### CONTOUR PLOTS
363367
#contour.negative_linestyle : dashed # dashed | solid

0 commit comments

Comments
 (0)