@@ -264,7 +264,7 @@ def _ticks(self, data, obj):
264
264
y_tick_position_string , y_tick_position = _get_tick_position (obj , "y" )
265
265
266
266
if x_tick_position == y_tick_position and x_tick_position is not None :
267
- self .axis_options .append ("tick pos=%s" % x_tick_position )
267
+ self .axis_options .append ("tick pos={}" . format ( x_tick_position ) )
268
268
else :
269
269
self .axis_options .append (x_tick_position_string )
270
270
self .axis_options .append (y_tick_position_string )
@@ -286,7 +286,7 @@ def _grid(self, obj, data):
286
286
xgridcolor = xlines [0 ].get_color ()
287
287
data , col , _ = color .mpl_color2xcolor (data , xgridcolor )
288
288
if col != "black" :
289
- self .axis_options .append ("x grid style={%s}" % col )
289
+ self .axis_options .append ("x grid style={{{}}}" . format ( col ) )
290
290
291
291
if obj .yaxis ._gridOnMajor :
292
292
self .axis_options .append ("ymajorgrids" )
@@ -298,7 +298,7 @@ def _grid(self, obj, data):
298
298
ygridcolor = ylines [0 ].get_color ()
299
299
data , col , _ = color .mpl_color2xcolor (data , ygridcolor )
300
300
if col != "black" :
301
- self .axis_options .append ("y grid style={%s}" % col )
301
+ self .axis_options .append ("y grid style={{{}}}" . format ( col ) )
302
302
303
303
return
304
304
@@ -380,11 +380,13 @@ def _colorbar(self, colorbar, data):
380
380
else :
381
381
self .axis_options .append ("colormap/" + mycolormap )
382
382
383
- self .axis_options .append ("point meta min=% .15g" % limits [0 ])
384
- self .axis_options .append ("point meta max=% .15g" % limits [1 ])
383
+ self .axis_options .append ("point meta min={: .15g}" . format ( limits [0 ]) )
384
+ self .axis_options .append ("point meta max={: .15g}" . format ( limits [1 ]) )
385
385
386
386
if colorbar_styles :
387
- self .axis_options .append ("colorbar style={%s}" % "," .join (colorbar_styles ))
387
+ self .axis_options .append (
388
+ "colorbar style={{{}}}" .format ("," .join (colorbar_styles ))
389
+ )
388
390
389
391
return
390
392
@@ -403,8 +405,8 @@ def _subplot(self, obj, data):
403
405
self .subplot_index = geom [2 ] + 1
404
406
if "is_in_groupplot_env" not in data or not data ["is_in_groupplot_env" ]:
405
407
self .content .append (
406
- "\\ begin{groupplot}[group style="
407
- "{group size=%.d by %.d} ]\n " % (geom [1 ], geom [0 ])
408
+ "\\ begin{{ groupplot} }[group style="
409
+ "{{ group size={} by {}}} ]\n " . format (geom [1 ], geom [0 ])
408
410
)
409
411
data ["is_in_groupplot_env" ] = True
410
412
data ["pgfplots libs" ].add ("groupplots" )
@@ -414,7 +416,7 @@ def _subplot(self, obj, data):
414
416
415
417
def _get_label_rotation_and_horizontal_alignment (obj , data , axes_obj ):
416
418
tick_label_text_width = None
417
- tick_label_text_width_identifier = "%s tick label text width" % axes_obj
419
+ tick_label_text_width_identifier = "{} tick label text width" . format ( axes_obj )
418
420
if tick_label_text_width_identifier in data ["extra axis options" ]:
419
421
tick_label_text_width = data ["extra axis options [base]" ][
420
422
tick_label_text_width_identifier
@@ -446,59 +448,65 @@ def _get_label_rotation_and_horizontal_alignment(obj, data, axes_obj):
446
448
values = []
447
449
448
450
if any (tick_labels_rotation ) != 0 :
449
- values .append ("rotate=%d" % tick_labels_rotation [0 ])
451
+ values .append ("rotate={}" . format ( tick_labels_rotation [0 ]) )
450
452
451
453
if tick_label_text_width :
452
- values .append ("align=%s" % tick_labels_horizontal_alignment [0 ])
453
- values .append ("text width=%s" % tick_label_text_width )
454
+ values .append ("align={}" . format ( tick_labels_horizontal_alignment [0 ]) )
455
+ values .append ("text width={}" . format ( tick_label_text_width ) )
454
456
else :
455
457
print (
456
- "Horizontal alignment will be ignored as no '%s tick "
457
- "label text width' has been passed in the 'extra' "
458
- "parameter" % axes_obj
458
+ (
459
+ "Horizontal alignment will be ignored as no '{} tick "
460
+ "label text width' has been passed in the 'extra' "
461
+ "parameter"
462
+ ).format (axes_obj )
459
463
)
460
464
461
465
if values :
462
- label_style = "%sticklabel style = {%s}" % (axes_obj , "," .join (values ))
466
+ label_style = "{}ticklabel style = {{{}}}" .format (
467
+ axes_obj , "," .join (values )
468
+ )
463
469
else :
464
470
values = []
465
471
466
472
if tick_labels_rotation_same_value :
467
- values .append ("rotate=%d" % tick_labels_rotation [0 ])
473
+ values .append ("rotate={}" . format ( tick_labels_rotation [0 ]) )
468
474
else :
469
475
values .append (
470
- "rotate={%s,0}[\\ ticknum]"
471
- % "," .join (str (x ) for x in tick_labels_rotation )
476
+ "rotate={{{},0}}[\\ ticknum]" .format (
477
+ "," .join (str (x ) for x in tick_labels_rotation )
478
+ )
472
479
)
473
480
474
481
if tick_label_text_width :
475
482
if tick_labels_horizontal_alignment_same_value :
476
- values .append ("align=%s" % tick_labels_horizontal_alignment [0 ])
477
- values .append ("text width=%s" % tick_label_text_width )
483
+ values .append ("align={}" . format ( tick_labels_horizontal_alignment [0 ]) )
484
+ values .append ("text width={}" . format ( tick_label_text_width ) )
478
485
else :
479
486
for idx , x in enumerate (tick_labels_horizontal_alignment ):
480
- label_style += "%s_tick_label_ha_%d/.initial = %s" % (
481
- axes_obj ,
482
- idx ,
483
- x ,
487
+ label_style += "{}_tick_label_ha_{}/.initial = {}" .format (
488
+ axes_obj , idx , x
484
489
)
485
490
486
491
values .append (
487
- "align=\\ pgfkeysvalueof{/pgfplots/"
488
- "%s_tick_label_ha_\\ ticknum}" % axes_obj
492
+ "align=\\ pgfkeysvalueof{{/pgfplots/{}_tick_label_ha_\\ ticknum}}" .format (
493
+ axes_obj
494
+ )
489
495
)
490
- values .append ("text width=%s" % tick_label_text_width )
496
+ values .append ("text width={}" . format ( tick_label_text_width ) )
491
497
else :
492
498
print (
493
- "Horizontal alignment will be ignored as no '%s tick "
494
- "label text width' has been passed in the 'extra' "
495
- "parameter" % axes_obj
499
+ (
500
+ "Horizontal alignment will be ignored as no '{} tick "
501
+ "label text width' has been passed in the 'extra' "
502
+ "parameter"
503
+ ).format (axes_obj )
496
504
)
497
505
498
506
label_style = (
499
- "every %s tick label/.style = {\n "
500
- "%s \n "
501
- "}" % (axes_obj , ",\n " .join (values ))
507
+ "every {} tick label/.style = { {\n "
508
+ "{} \n "
509
+ "}}" . format (axes_obj , ",\n " .join (values ))
502
510
)
503
511
504
512
return label_style
@@ -520,7 +528,7 @@ def _get_tick_position(obj, axes_obj):
520
528
521
529
major_ticks_position = None
522
530
if not major_ticks_bottom_show_all and not major_ticks_top_show_all :
523
- position_string = "%smajorticks =false" % axes_obj
531
+ position_string = "{}majorticks =false" . format ( axes_obj )
524
532
elif major_ticks_bottom_show_all and major_ticks_top_show_all :
525
533
major_ticks_position = "both"
526
534
elif major_ticks_bottom_show_all :
@@ -529,7 +537,7 @@ def _get_tick_position(obj, axes_obj):
529
537
major_ticks_position = "right"
530
538
531
539
if major_ticks_position :
532
- position_string = "%stick pos=%s" % (axes_obj , major_ticks_position )
540
+ position_string = "{}tick pos={}" . format (axes_obj , major_ticks_position )
533
541
534
542
return position_string , major_ticks_position
535
543
@@ -566,15 +574,17 @@ def _get_ticks(data, xy, ticks, ticklabels):
566
574
if data ["strict" ] or is_label_required :
567
575
if pgfplots_ticks :
568
576
axis_options .append (
569
- "%stick={%s}" % (xy , "," .join (["%.15g" % el for el in pgfplots_ticks ]))
577
+ "{}tick={{{}}}" .format (
578
+ xy , "," .join (["{:.15g}" .format (el ) for el in pgfplots_ticks ])
579
+ )
570
580
)
571
581
else :
572
582
val = "{}" if "minor" in xy else "\\ empty"
573
- axis_options .append ("%stick=%s" % (xy , val ))
583
+ axis_options .append ("{}tick={}" . format (xy , val ))
574
584
575
585
if is_label_required :
576
586
axis_options .append (
577
- "%sticklabels={%s}" % (xy , "," .join (pgfplots_ticklabels ))
587
+ "{}ticklabels={{{}}}" . format (xy , "," .join (pgfplots_ticklabels ))
578
588
)
579
589
return axis_options
580
590
@@ -705,9 +715,13 @@ def _handle_linear_segmented_color_map(cmap):
705
715
706
716
color_changes = []
707
717
for (k , x ) in enumerate (X ):
708
- color_changes .append ("rgb(%d%s)=(%.15g,%.15g,%.15g)" % ((x , unit ) + colors [k ]))
718
+ color_changes .append (
719
+ "rgb({}{})=({:.15g},{:.15g},{:.15g})" .format (* ((x , unit ) + colors [k ]))
720
+ )
709
721
710
- colormap_string = "{mymap}{[1%s]\n %s\n }" % (unit , ";\n " .join (color_changes ))
722
+ colormap_string = "{{mymap}}{{[1{}]\n {}\n }}" .format (
723
+ unit , ";\n " .join (color_changes )
724
+ )
711
725
is_custom_colormap = True
712
726
return (colormap_string , is_custom_colormap )
713
727
@@ -740,18 +754,22 @@ def _handle_listed_color_map(cmap):
740
754
unit = "pt"
741
755
if cmap .N is None or cmap .N == len (cmap .colors ):
742
756
colors = [
743
- "rgb(%d%s)=(%.15g,%.15g,%.15g)" % (k , unit , rgb [0 ], rgb [1 ], rgb [2 ])
757
+ "rgb({}{})=({:.15g},{:.15g},{:.15g})" .format (
758
+ k , unit , rgb [0 ], rgb [1 ], rgb [2 ]
759
+ )
744
760
for (k , rgb ) in enumerate (cmap .colors )
745
761
]
746
762
else :
747
763
reps = int (float (cmap .N ) / len (cmap .colors ) - 0.5 ) + 1
748
764
repeated_cols = reps * cmap .colors
749
765
colors = [
750
- "rgb(%d%s)=(%.15g,%.15g,%.15g)" % (k , unit , rgb [0 ], rgb [1 ], rgb [2 ])
766
+ "rgb({}{})=({:.15g},{:.15g},{:.15g})" .format (
767
+ k , unit , rgb [0 ], rgb [1 ], rgb [2 ]
768
+ )
751
769
for (k , rgb ) in enumerate (repeated_cols [: cmap .N ])
752
770
]
753
771
754
- colormap_string = "{mymap}{[1%s ]\n %s \n }" % (unit , ";\n " .join (colors ))
772
+ colormap_string = "{mymap}{[1{} ]\n {} \n }" . format (unit , ";\n " .join (colors ))
755
773
is_custom_colormap = True
756
774
return (colormap_string , is_custom_colormap )
757
775
0 commit comments