@@ -14,8 +14,7 @@ def _common_texification(string):
1414
1515class Axes :
1616 def __init__ (self , data , obj ): # noqa: C901
17- """Returns the PGFPlots code for an axis environment.
18- """
17+ """Returns the PGFPlots code for an axis environment."""
1918 self .content = []
2019
2120 # Are we dealing with an axis that hosts a colorbar? Skip then, those are
@@ -270,14 +269,14 @@ def _ticks(self, data, obj):
270269 self .axis_options .append ("tick align=center" )
271270
272271 # Set each rotation for every label
273- x_tick_rotation_and_horizontal_alignment = self . _get_label_rotation_and_horizontal_alignment (
274- obj , data , "x"
272+ x_tick_rotation_and_horizontal_alignment = (
273+ self . _get_label_rotation_and_horizontal_alignment ( obj , data , "x" )
275274 )
276275 if x_tick_rotation_and_horizontal_alignment :
277276 self .axis_options .append (x_tick_rotation_and_horizontal_alignment )
278277
279- y_tick_rotation_and_horizontal_alignment = self . _get_label_rotation_and_horizontal_alignment (
280- obj , data , "y"
278+ y_tick_rotation_and_horizontal_alignment = (
279+ self . _get_label_rotation_and_horizontal_alignment ( obj , data , "y" )
281280 )
282281 if y_tick_rotation_and_horizontal_alignment :
283282 self .axis_options .append (y_tick_rotation_and_horizontal_alignment )
@@ -431,11 +430,6 @@ def _subplot(self, obj, data):
431430 data ["pgfplots libs" ].add ("groupplots" )
432431
433432 def _get_label_rotation_and_horizontal_alignment (self , obj , data , x_or_y ):
434- tick_label_text_width = None
435- tick_label_text_width_identifier = f"{ x_or_y } tick label text width"
436- if tick_label_text_width_identifier in self .axis_options :
437- self .axis_options .remove (tick_label_text_width_identifier )
438-
439433 label_style = ""
440434
441435 major_tick_labels = (
@@ -447,6 +441,10 @@ def _get_label_rotation_and_horizontal_alignment(self, obj, data, x_or_y):
447441 if not major_tick_labels :
448442 return None
449443
444+ tick_label_text_width_identifier = f"{ x_or_y } tick label text width"
445+ if tick_label_text_width_identifier in self .axis_options :
446+ self .axis_options .remove (tick_label_text_width_identifier )
447+
450448 tick_labels_rotation = [label .get_rotation () for label in major_tick_labels ]
451449 tick_labels_rotation_same_value = len (set (tick_labels_rotation )) == 1
452450
@@ -468,9 +466,10 @@ def _get_label_rotation_and_horizontal_alignment(self, obj, data, x_or_y):
468466
469467 # Horizontal alignment will be ignored if no 'x/y tick label text width' has
470468 # been passed in the 'extra' parameter
471- if tick_label_text_width :
472- values .append (f"align={ tick_labels_horizontal_alignment [0 ]} " )
473- values .append (f"text width={ tick_label_text_width } " )
469+ # tick_label_text_width = None
470+ # if tick_label_text_width:
471+ # values.append(f"align={tick_labels_horizontal_alignment[0]}")
472+ # values.append(f"text width={tick_label_text_width}")
474473
475474 if values :
476475 label_style = "{}ticklabel style = {{{}}}" .format (
@@ -490,18 +489,18 @@ def _get_label_rotation_and_horizontal_alignment(self, obj, data, x_or_y):
490489
491490 # Ignore horizontal alignment if no '{x,y} tick label text width' has been
492491 # passed in the 'extra' parameter
493- if tick_label_text_width :
494- if tick_labels_horizontal_alignment_same_value :
495- values .append (f"align={ tick_labels_horizontal_alignment [0 ]} " )
496- values .append (f"text width={ tick_label_text_width } " )
497- else :
498- for idx , x in enumerate (tick_labels_horizontal_alignment ):
499- label_style += f"{ x_or_y } _tick_label_ha_{ idx } /.initial = { x } "
500-
501- values .append (
502- f"align=\\ pgfkeysvalueof{{/pgfplots/{ x_or_y } _tick_label_ha_\\ ticknum}}"
503- )
504- values .append (f"text width={ tick_label_text_width } " )
492+ # if tick_label_text_width:
493+ # if tick_labels_horizontal_alignment_same_value:
494+ # values.append(f"align={tick_labels_horizontal_alignment[0]}")
495+ # values.append(f"text width={tick_label_text_width}")
496+ # else:
497+ # for idx, x in enumerate(tick_labels_horizontal_alignment):
498+ # label_style += f"{x_or_y}_tick_label_ha_{idx}/.initial = {x}"
499+
500+ # values.append(
501+ # f"align=\\pgfkeysvalueof{{/pgfplots/{x_or_y}_tick_label_ha_\\ticknum}}"
502+ # )
503+ # values.append(f"text width={tick_label_text_width}")
505504
506505 label_style = (
507506 "every {} tick label/.style = {{\n "
@@ -600,8 +599,7 @@ def _get_ticks(data, xy, ticks, ticklabels):
600599
601600
602601def _is_colorbar_heuristic (obj ):
603- """Find out if the object is in fact a color bar.
604- """
602+ """Find out if the object is in fact a color bar."""
605603 # TODO come up with something more accurate here
606604 # Might help:
607605 # TODO Are the colorbars exactly the l.collections.PolyCollection's?
@@ -664,7 +662,6 @@ def _handle_linear_segmented_color_map(cmap, data):
664662 k_red = 0
665663 k_green = 0
666664 k_blue = 0
667- x = 0.0
668665 colors = []
669666 X = []
670667 while True :
@@ -782,8 +779,7 @@ def _handle_listed_color_map(cmap, data):
782779
783780
784781def _scale_to_int (X , max_val ):
785- """Scales the array X such that it contains only integers.
786- """
782+ """Scales the array X such that it contains only integers."""
787783 # if max_val is None:
788784 # X = X / _gcd_array(X)
789785 X = X / max (1 / max_val , _gcd_array (X ))
@@ -817,8 +813,7 @@ def _gcd(a, b):
817813
818814
819815def _linear_interpolation (x , X , Y ):
820- """Given two data points [X,Y], linearly interpolate those at x.
821- """
816+ """Given two data points [X,Y], linearly interpolate those at x."""
822817 return (Y [1 ] * (x - X [0 ]) + Y [0 ] * (X [1 ] - x )) / (X [1 ] - X [0 ])
823818
824819
0 commit comments