在 matplotlib 中制作更长的子图刻度线? [英] Make longer subplot tick marks in matplotlib?

查看:60
本文介绍了在 matplotlib 中制作更长的子图刻度线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to alter the tick marks along the axes of a python multipanel subplot. I have two panels that share a common x-axis. I have made the border around the plot thicker as well as making all of the tick marks along the axes thicker. I have two questions:

我怎样才能使所有刻度线(两个轴)都更长一些,使它们更明显?

How can I make all tick marks (both axes) longer so they are more visible?

如何在主要刻度线之间添加较小但仍值得注意的刻度线?

How do I add smaller but still noticable tick marks between major tick marks?

这是迄今为止我所拥有的最小工作示例.

Here is a minimum working example of what I have so far.

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()

推荐答案

尝试以下操作:

#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 重复相同的操作.这对您有用吗?

You can repeat the same for ax2. Does this work for you?

这篇关于在 matplotlib 中制作更长的子图刻度线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆