【问题标题】:Make longer subplot tick marks in matplotlib?在matplotlib中制作更长的子图刻度线?
【发布时间】:2013-01-05 03:55:48
【问题描述】:

我正在尝试沿 python 多面板子图的轴更改刻度线。我有两个面板共享一个共同的 x 轴。我使绘图周围的边框更粗,并使沿轴的所有刻度线更粗。我有两个问题:

如何使所有刻度线(两个轴)更长,以便更明显?

如何在主要刻度线之间添加较小但仍显着的刻度线?

这是我目前所拥有的一个最低限度的工作示例。

from numpy import *
from scipy import *
from pylab import *
from random import *
import pylab
import matplotlib.pyplot as plt


#make the axis border thick
pylab.rc("axes", linewidth=4.0)
pylab.rc("lines", markeredgewidth=4)


#create a figure with two panels that shares the x-axis
f, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False)
#example figure1
ax1.plot(range(2),range(2),linewidth=2)
#example figure 2
ax2.plot(range(2),range(2),linewidth=2)



# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)
show()

【问题讨论】:

    标签: python matplotlib subplot


    【解决方案1】:

    尝试以下方法:

    #example figure1
    ax1.plot(range(2),range(2),linewidth=2)
    ax1.minorticks_on()
    ax1.tick_params('both', length=20, width=2, which='major')
    ax1.tick_params('both', length=10, width=1, which='minor')
    

    您可以对ax2 重复相同的操作。这对你有用吗?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 2015-09-07
    • 2014-06-30
    相关资源
    最近更新 更多