Movatterモバイル変換


[0]ホーム

URL:


You are reading an old version of the documentation (v2.0.0). For the latest version seehttps://matplotlib.org/stable/
matplotlib

Navigation


Travis-CI:

Related Topics

This Page

Quick search

ticks_and_spines example code: spines_demo_bounds.py

(Source code,png,pdf)

../../_images/spines_demo_bounds.png
"""Demo of spines using custom bounds to limit the extent of the spine."""importnumpyasnpimportmatplotlib.pyplotaspltx=np.linspace(0,2*np.pi,50)y=np.sin(x)y2=y+0.1*np.random.normal(size=x.shape)fig,ax=plt.subplots()ax.plot(x,y,'k--')ax.plot(x,y2,'ro')# set ticks and tick labelsax.set_xlim((0,2*np.pi))ax.set_xticks([0,np.pi,2*np.pi])ax.set_xticklabels(['0','$\pi$','2$\pi$'])ax.set_ylim((-1.5,1.5))ax.set_yticks([-1,0,1])# Only draw spine between the y-ticksax.spines['left'].set_bounds(-1,1)# Hide the right and top spinesax.spines['right'].set_visible(False)ax.spines['top'].set_visible(False)# Only show ticks on the left and bottom spinesax.yaxis.set_ticks_position('left')ax.xaxis.set_ticks_position('bottom')plt.show()

Keywords: python, matplotlib, pylab, example, codex (seeSearch examples)

© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2016 The Matplotlib development team. Last updated on Feb 20, 2017. Created usingSphinx 1.5.2.

[8]ページ先頭

©2009-2025 Movatter.jp