matplotlib ticks thickness

后端 未结 3 880
梦如初夏
梦如初夏 2020-12-03 02:44

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_ti         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-03 03:11

    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

提交回复
热议问题