@@ -13,8 +13,8 @@ def __init__(self, data, obj):
1313 """
1414 self .content = []
1515
16- # Are we dealing with an axis that hosts a colorbar? Skip then, those
17- # are treated implicitily by the associated axis.
16+ # Are we dealing with an axis that hosts a colorbar? Skip then, those are
17+ # treated implicitily by the associated axis.
1818 self .is_colorbar = _is_colorbar_heuristic (obj )
1919 if self .is_colorbar :
2020 return
@@ -51,8 +51,7 @@ def __init__(self, data, obj):
5151 self .axis_options .append (u"ylabel={{{}}}" .format (ylabel ))
5252
5353 # Axes limits.
54- # Sort the limits so make sure that the smaller of the two is actually
55- # *min.
54+ # Sort the limits so make sure that the smaller of the two is actually *min.
5655 ff = data ["float format" ]
5756 xlim = sorted (list (obj .get_xlim ()))
5857 self .axis_options .append (("xmin=" + ff + ", xmax=" + ff ).format (* xlim ))
@@ -71,6 +70,12 @@ def __init__(self, data, obj):
7170 "log basis y={{{}}}" .format (_try_f2i (obj .yaxis ._scale .base ))
7271 )
7372
73+ # Possible values for get_axisbelow():
74+ # True (zorder = 0.5): Ticks and gridlines are below all Artists.
75+ # 'line' (zorder = 1.5): Ticks and gridlines are above patches (e.g.
76+ # rectangles) but still below lines / markers.
77+ # False (zorder = 2.5): Ticks and gridlines are above patches and lines /
78+ # markers.
7479 if not obj .get_axisbelow ():
7580 self .axis_options .append ("axis on top" )
7681
@@ -108,12 +113,7 @@ def __init__(self, data, obj):
108113 self .axis_options .append ("axis line style={{{}}}" .format (col ))
109114
110115 # background color
111- try :
112- # mpl 2.*
113- bgcolor = obj .get_facecolor ()
114- except AttributeError :
115- # mpl 1.*
116- bgcolor = obj .get_axis_bgcolor ()
116+ bgcolor = obj .get_facecolor ()
117117
118118 data , col , _ = color .mpl_color2xcolor (data , bgcolor )
119119 if col != "white" :
@@ -201,13 +201,31 @@ def _ticks(self, data, obj):
201201 )
202202 )
203203
204+ try :
205+ l0 = obj .get_xticklines ()[0 ]
206+ except IndexError :
207+ pass
208+ else :
209+ c0 = l0 .get_color ()
210+ data , xtickcolor , _ = color .mpl_color2xcolor (data , c0 )
211+ self .axis_options .append ("xtick style={{color={}}}" .format (xtickcolor ))
212+
213+ try :
214+ l0 = obj .get_yticklines ()[0 ]
215+ except IndexError :
216+ pass
217+ else :
218+ c0 = l0 .get_color ()
219+ data , ytickcolor , _ = color .mpl_color2xcolor (data , c0 )
220+ self .axis_options .append ("ytick style={{color={}}}" .format (ytickcolor ))
221+
204222 # Find tick direction
205223 # For new matplotlib versions, we could replace the direction getter by
206224 # `get_ticks_direction()`, see
207- # <https://github.com/matplotlib/matplotlib/pull/5290>.
208- # Unfortunately, _tickdir doesn't seem to be quite accurate. See
209- # <https://github.com/matplotlib/matplotlib/issues/5311>.
210- # For now, just take the first tick direction of each of the axes.
225+ # <https://github.com/matplotlib/matplotlib/pull/5290>. Unfortunately, _tickdir
226+ # doesn't seem to be quite accurate. See
227+ # <https://github.com/matplotlib/matplotlib/issues/5311>. For now, just take
228+ # the first tick direction of each of the axes.
211229 x_tick_dirs = [tick ._tickdir for tick in obj .xaxis .get_major_ticks ()]
212230 y_tick_dirs = [tick ._tickdir for tick in obj .yaxis .get_major_ticks ()]
213231 if x_tick_dirs or y_tick_dirs :
@@ -256,9 +274,8 @@ def _ticks(self, data, obj):
256274
257275 def _grid (self , obj , data ):
258276 # Don't use get_{x,y}gridlines for gridlines; see discussion on
259- # <http://sourceforge.net/p/matplotlib/mailman/message/25169234/>
260- # Coordinate of the lines are entirely meaningless, but styles
261- # (colors,...) are respected.
277+ # <http://sourceforge.net/p/matplotlib/mailman/message/25169234/> Coordinate of
278+ # the lines are entirely meaningless, but styles (colors,...) are respected.
262279 if obj .xaxis ._gridOnMajor :
263280 self .axis_options .append ("xmajorgrids" )
264281 if obj .xaxis ._gridOnMinor :
@@ -516,15 +533,14 @@ def _get_tick_position(obj, axes_obj):
516533
517534
518535def _get_ticks (data , xy , ticks , ticklabels ):
519- """
520- Gets a {'x','y'}, a number of ticks and ticks labels, and returns the
536+ """Gets a {'x','y'}, a number of ticks and ticks labels, and returns the
521537 necessary axis options for the given configuration.
522538 """
523539 axis_options = []
524540 pgfplots_ticks = []
525541 pgfplots_ticklabels = []
526542 is_label_required = False
527- for ( tick , ticklabel ) in zip (ticks , ticklabels ):
543+ for tick , ticklabel in zip (ticks , ticklabels ):
528544 pgfplots_ticks .append (tick )
529545 # store the label anyway
530546 label = ticklabel .get_text ()
@@ -533,17 +549,17 @@ def _get_ticks(data, xy, ticks, ticklabels):
533549 pgfplots_ticklabels .append (label )
534550 else :
535551 is_label_required = True
536- # Check if the label is necessary. If one of the labels is, then all
537- # of them must appear in the TikZ plot.
552+ # Check if the label is necessary. If one of the labels is, then all of them
553+ # must appear in the TikZ plot.
538554 if label :
539555 try :
540556 label_float = float (label .replace (u"\N{MINUS SIGN} " , "-" ))
541557 is_label_required = is_label_required or (label and label_float != tick )
542558 except ValueError :
543559 is_label_required = True
544560
545- # Leave the ticks to PGFPlots if not in STRICT mode and if there are no
546- # explicit labels.
561+ # Leave the ticks to PGFPlots if not in STRICT mode and if there are no explicit
562+ # labels.
547563 if data ["strict" ] or is_label_required :
548564 if pgfplots_ticks :
549565 ff = data ["float format" ]
0 commit comments