You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unable to set label color or other text properties
Code for reproduction
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
fig, ax = plt.subplots(figsize=(5,6),dpi=200)
#hiding the axis numbers
ax.axes.xaxis.set_visible(False)
ax.axes.yaxis.set_visible(False)
#setting the axis dimensions
ax.set_xlim((-250, 250))
ax.set_ylim((422.5, -47.5))
#setting the background color as black ('k') for a better visualization
ax.set_facecolor('k')
fig.set_facecolor('k')
cbaxes = inset_axes(ax, width="5%",
height="50%",
loc='lower left',
bbox_to_anchor=(.7, 0.07, 5, .08),
bbox_transform=ax.transAxes,
borderpad=0,
)
bar_palette = mpl.cm.inferno
bar = mpl.colorbar.ColorbarBase(cbaxes, cmap=bar_palette, orientation='horizontal')
# creating ticks
bar.set_ticks([0,1])
bar.set_ticklabels(ticklabels=['Low', 'High'], color='white')
Actual outcome
TypeError: set_ticklabels() got an unexpected keyword argument 'color'
Expected outcome
I need the labels to be white because the background is black IMPORTANT
If you put 'white' instead of 'k' in ax.set_facecolor('k') and remove color='white' from bar.set_ticklabels
you can see that the labels are properly created, but they are black and apparently there is no way to make them
change.
Yes, set_ticklabels should probably pass kwargs down to the base axes. #20054 is meant to make this easier, though this particular case has not been addressed yet.
In the meantime, you can do bar.ax.xaxis.set_ticklabels(...) and it will work as you expect.
Yes, set_ticklabels should probably pass kwargs down to the base axes. #20054 is meant to make this easier, though this particular case has not been addressed yet.
In the meantime, you can do bar.ax.xaxis.set_ticklabels(...) and it will work as you expect.
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug summary
Unable to set label color or other text properties
Code for reproduction
Actual outcome
TypeError: set_ticklabels() got an unexpected keyword argument 'color'
Expected outcome
I need the labels to be white because the background is black
IMPORTANT
If you put 'white' instead of 'k' in ax.set_facecolor('k') and remove color='white' from bar.set_ticklabels
you can see that the labels are properly created, but they are black and apparently there is no way to make them
change.
Matplotlib version
Thanks to anyone who can help!
The text was updated successfully, but these errors were encountered: