Skip to content

Commit 7031858

Browse files
committed
Ticklabel rc bugfix
1 parent 27ea3dd commit 7031858

1 file changed

Lines changed: 37 additions & 19 deletions

File tree

‎proplot/base.py‎

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,37 +1594,55 @@ def _rcupdate(self):
15941594
# Axis settings
15951595
for name,axis in zip('xy', (self.xaxis, self.yaxis)):
15961596
# Optionally apply an x/y axis specific color
1597-
axis_side = axis.get_label_position()
1598-
axis_color = rc[name + 'color']
1599-
axis_color = {'color': axis_color} if axis_color else {}
1597+
label_side = axis.get_label_position()
1598+
axis_color = rc[name + 'color'] # the special 'xcolor' and 'ycolor' property, for changing color on one spine
16001599
sides = ('bottom','top') if name=='x' else ('left','right')
16011600

16021601
# Update the rcParams according to user input.
16031602
# The ticks/spines can be on both sides or just one, while the
16041603
# tick labels and axis label on just one side
16051604
for side in sides:
16061605
# Simply updates the spines and whatnot
1607-
override_color = axis_color if side==axis_side else {}
1608-
kw = rc.fill({'lw':'axes.linewidth', 'color':'axes.edgecolor'})
1609-
self.spines[side].update({**kw, **axis_color})
1610-
1611-
# Tick marks
1612-
# NOTE: We decide that tick location should be controlled only
1613-
# by format(), so don't override that here.
1614-
kw_both = rc.fill({'color': name + 'tick.color'})
1615-
for which in ('major','minor'):
1616-
kw = rc[name + 'tick.' + which]
1617-
axis.set_tick_params(which=which, **kw, **{**kw_both, **axis_color})
1606+
override_color = None
1607+
if side==label_side:
1608+
override_color = axis_color
1609+
kw = rc.fill({
1610+
'lw': 'axes.linewidth',
1611+
'color': 'axes.edgecolor'
1612+
})
1613+
if override_color:
1614+
kw['color'] = override_color
1615+
self.spines[side].update(kw)
1616+
1617+
# Tick marks
1618+
# NOTE: We decide that tick location should be controlled only
1619+
# by format(), so don't override that here.
1620+
kw = rc.fill({
1621+
'color': name + 'tick.color',
1622+
'labelcolor': 'axes.edgecolor',
1623+
'labelsize': 'axes.labelsize'})
1624+
if override_color:
1625+
kw['color'] = override_color
1626+
axis.set_tick_params(which='both', **kw)
1627+
for which in ('major','minor'):
1628+
axis.set_tick_params(which=which, **rc[name + 'tick.' + which])
16181629

16191630
# Tick labels
1620-
# NOTE: Assumed
1621-
kw = rc.fill({'color':'axes.edgecolor', 'fontname':'fontname', 'fontsize': name + 'tick.labelsize'})
1631+
# TODO: Figure out how to change fontname for all ticks, like in
1632+
# set_tick_params. But fontname is global.
1633+
kw = rc.fill({'fontname': 'fontname'})
16221634
for t in axis.get_ticklabels():
1623-
t.update({**kw, **axis_color})
1635+
t.update(kw)
16241636

16251637
# Axis label
1626-
kw = rc.fill({'color':'axes.edgecolor', 'fontname':'fontname', 'fontsize':'axes.labelsize', 'weight':'axes.labelweight'})
1627-
axis.label.update({**kw, **axis_color})
1638+
kw = rc.fill({
1639+
'color': 'axes.edgecolor',
1640+
'fontname': 'fontname',
1641+
'fontsize': 'axes.labelsize',
1642+
'weight': 'axes.labelweight'})
1643+
if override_color:
1644+
kw['color'] = override_color
1645+
axis.label.update(kw)
16281646

16291647
# Manually update gridlines
16301648
for grid,ticks in zip(['grid','gridminor'],[axis.get_major_ticks(), axis.get_minor_ticks()]):

0 commit comments

Comments
 (0)