Is there a way to change the color of an axis (not the ticks) in matplotlib? I have been looking through the docs for Axes, Axis, and Artist, but no luck; the matplotlib gallery also has no hint. Any idea?
To set the color for X-axis and Y-axis, we can use the set_color() method (Set both the edgecolor and the facecolor). To set the ticks color, use tick_params method for axes. Used arguments are axis ='x' (or y or both) and color = 'red' (or green or yellow or ...etc.)
Python Tkinter Color Label We can apply color on the Label widget and Label Text. To color the widget label, the background or bg keyword is used, and to change the text color of the label widget, the foreground or fg keyword is used. In this example, we have a colored label widget and label text.
axis() method allows you to set the x and y limits with a single call, by passing a list which specifies [xmin, xmax, ymin, ymax] : In [11]: plt. plot(x, np.
When using figures, you can easily change the spine color with:
ax.spines['bottom'].set_color('#dddddd') ax.spines['top'].set_color('#dddddd') ax.spines['right'].set_color('red') ax.spines['left'].set_color('red')
Use the following to change only the ticks:
which="both"
changes both the major and minor tick colorsax.tick_params(axis='x', colors='red') ax.tick_params(axis='y', colors='red')
And the following to change only the label:
ax.yaxis.label.set_color('red') ax.xaxis.label.set_color('red')
And finally the title:
ax.title.set_color('red')
For the record, this is how I managed to make it work:
fig = pylab.figure() ax = fig.add_subplot(1, 1, 1) for child in ax.get_children(): if isinstance(child, matplotlib.spines.Spine): child.set_color('#dddddd')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With