I want to write a callable function that sets my matplotlib rc Parameters uniformly for all my different plots. So far it is just a block that I copy to every file and boils down to this:
import matplotlib as mpl
grey = '#808080'
mpl.rcParams['axes.linewidth'] = 0.3
mpl.rcParams['axes.edgecolor'] = grey
I am doing this to have thinner axes and to make my data stick out by having everything else a little grey-ish. But I cannot find a way to set the tick edge color to grey in the rc. I am looking for something like
'axes.tickedgecolor'
which doesn't seem to exist, sadly.
A way of doing it without rc is described here: Elegantly changing the color of a plot frame in matplotlib
I hope somebody can help, thanks!
Edit: Just to clarify: I found the option
mpl.rcParams['tick.color'] = '#808080'
but it also changes the tick labels, which I want to remain black!
Okay, I found a little workaround to my answer that fulfills my needs:
import matplotlib as mpl
grey = '#808080'
mpl.rcParams['axes.linewidth'] = 0.3
mpl.rcParams['axes.edgecolor'] = grey
mpl.rcParams['xtick.color'] = grey
mpl.rcParams['ytick.color'] = grey
mpl.rcParams['axes.labelcolor'] = "black"
Although xtick.color
also changes the label color, you can overwrite the label color afterwards.
Edit: Somehow this only works for a single plot. For a figure with 6 subplots it does not work.
Edit2: I couldn't get it to work with rcParams, so I changed the ticks during the subplotting routine
ax.tick_params('both', length=2, width=0.3, which='major', color=grey)
This made it work.
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