Is there a way to increase the thickness and size of ticks in matplotlib without having to write a long piece of code like this:
for line in ax1.yaxis.get_ticklines(): line.set_markersize(25) line.set_markeredgewidth(3)
The problem with this piece of code is that it uses a loop which costs usually a lot of CPU usage.
Matplotlib x-axis label boldPass the fontweight parameter to the xlabel() function to make the label bold. We import the matplotlib.
Demonstrate how to use major and minor tickers. The two relevant classes are Locator s and Formatter s. Locators determine where the ticks are, and formatters control the formatting of tick labels.
Ticks are the markers denoting data points on axes. Matplotlib has so far - in all our previous examples - automatically taken over the task of spacing points on the axis. Matplotlib's default tick locators and formatters are designed to be generally sufficient in many common situations.
A simpler way is to use the set_tick_params
function of axis
objects:
ax.xaxis.set_tick_params(width=5) ax.yaxis.set_tick_params(width=5)
Doing it this way means you can change this on a per-axis basis with out worrying about global state and with out making any assumptions about the internal structure of mpl objects.
If you want to set this for all the ticks in your axes,
ax = plt.gca() ax.tick_params(width=5,...)
Take a look at set_tick_params
doc and tick_params valid keywords
You can change all matplotlib
defaults using rcParams
like in
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt # set tick width mpl.rcParams['xtick.major.size'] = 20 mpl.rcParams['xtick.major.width'] = 4 mpl.rcParams['xtick.minor.size'] = 10 mpl.rcParams['xtick.minor.width'] = 2 x = np.linspace(0., 10.) plt.plot(x, np.sin(x)) plt.show()
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