由于它们是在绘图区域内绘制的,因此许多matplotlib图中的数据会使轴刻度变得模糊.更好的方法是绘制从轴向外延伸的刻度线,如ggplotR的绘图系统中的默认值.
从理论上讲,这可以通过重新绘制与所述刻度线来完成TICKDOWN和TICKLEFT线样式的x轴和y轴分别蜱:
import matplotlib.pyplot as plt
import matplotlib.ticker as mplticker
import matplotlib.lines as mpllines
# Create everything, plot some data stored in `x` and `y`
fig = plt.figure()
ax = fig.gca()
plt.plot(x, y)
# Set position and labels of major and minor ticks on the y-axis
# Ignore the details: the point is that there are both major and minor ticks
ax.yaxis.set_major_locator(mplticker.MultipleLocator(1.0))
ax.yaxis.set_minor_locator(mplticker.MultipleLocator(0.5))
ax.xaxis.set_major_locator(mplticker.MultipleLocator(1.0))
ax.xaxis.set_minor_locator(mplticker.MultipleLocator(0.5))
# Try to set the tick markers …Run Code Online (Sandbox Code Playgroud) R曲线自动设置x和y限制,以在数据和轴之间放置一些空间.我想知道matplotlib是否有办法自动完成相同的操作.如果没有,是否有一个良好的公式或"经验法则"R如何设置其轴限制?
出于一个奇怪的原因,我找不到在Python的matplotlibrc文件中指定spines配置的方法.有关如何使matplotlib默认不绘制上右刺的任何想法? 刺http://matplotlib.sourceforge.net/_images/whats_new_99_spines.png
有关matplotlib中刺的信息的更多信息,请点击此处
谢谢