@@ -965,7 +965,7 @@ def _print_ps(self, outfile, format, *args, **kwargs):
965965
966966 def _print_figure (self , outfile , format , dpi = 72 , facecolor = 'w' , edgecolor = 'w' ,
967967 orientation = 'portrait' , isLandscape = False , papertype = None ,
968- ** kwargs ):
968+ metadata = None , ** kwargs ):
969969 """
970970 Render the figure to hardcopy. Set the figure patch face and
971971 edge colors. This is useful because some of the GUIs have a
@@ -978,6 +978,9 @@ def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w',
978978
979979 If outfile is a file object, a stand-alone PostScript file is
980980 written into this file object.
981+
982+ metadata must be a dictionary. Currently, only the value for
983+ the key 'Creator' is used.
981984 """
982985 isEPSF = format == 'eps'
983986 passed_in_file_object = False
@@ -1059,13 +1062,18 @@ def write(self, *kl, **kwargs):
10591062 self .figure .set_facecolor (origfacecolor )
10601063 self .figure .set_edgecolor (origedgecolor )
10611064
1065+ # check for custom metadata
1066+ if metadata is not None and 'Creator' in metadata :
1067+ creator_str = metadata ['Creator' ]
1068+ else :
1069+ creator_str = "matplotlib version " + __version__ + \
1070+ ", http://matplotlib.org/"
10621071 def print_figure_impl ():
10631072 # write the PostScript headers
10641073 if isEPSF : print ("%!PS-Adobe-3.0 EPSF-3.0" , file = fh )
10651074 else : print ("%!PS-Adobe-3.0" , file = fh )
10661075 if title : print ("%%Title: " + title , file = fh )
1067- print (("%%Creator: matplotlib version "
1068- + __version__ + ", http://matplotlib.org/" ), file = fh )
1076+ print ("%%Creator: " + creator_str , file = fh )
10691077 # get source date from SOURCE_DATE_EPOCH, if set
10701078 # See https://reproducible-builds.org/specs/source-date-epoch/
10711079 source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
@@ -1189,12 +1197,15 @@ def do_nothing():
11891197 os .chmod (outfile , mode )
11901198
11911199 def _print_figure_tex (self , outfile , format , dpi , facecolor , edgecolor ,
1192- orientation , isLandscape , papertype ,
1200+ orientation , isLandscape , papertype , metadata = None ,
11931201 ** kwargs ):
11941202 """
11951203 If text.usetex is True in rc, a temporary pair of tex/eps files
11961204 are created to allow tex to manage the text layout via the PSFrags
11971205 package. These files are processed to yield the final ps or eps file.
1206+
1207+ metadata must be a dictionary. Currently, only the value for
1208+ the key 'Creator' is used.
11981209 """
11991210 isEPSF = format == 'eps'
12001211 if is_string_like (outfile ):
@@ -1249,14 +1260,20 @@ def write(self, *kl, **kwargs):
12491260 self .figure .set_facecolor (origfacecolor )
12501261 self .figure .set_edgecolor (origedgecolor )
12511262
1263+ # check for custom metadata
1264+ if metadata is not None and 'Creator' in metadata :
1265+ creator_str = metadata ['Creator' ]
1266+ else :
1267+ creator_str = "matplotlib version " + __version__ + \
1268+ ", http://matplotlib.org/"
1269+
12521270 # write to a temp file, we'll move it to outfile when done
12531271 fd , tmpfile = mkstemp ()
12541272 with io .open (fd , 'w' , encoding = 'latin-1' ) as fh :
12551273 # write the Encapsulated PostScript headers
12561274 print ("%!PS-Adobe-3.0 EPSF-3.0" , file = fh )
12571275 if title : print ("%%Title: " + title , file = fh )
1258- print (("%%Creator: matplotlib version "
1259- + __version__ + ", http://matplotlib.org/" ), file = fh )
1276+ print ("%%Creator: " + creator_str , file = fh )
12601277 # get source date from SOURCE_DATE_EPOCH, if set
12611278 # See https://reproducible-builds.org/specs/source-date-epoch/
12621279 source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
0 commit comments