Saell I have got problem using semilogy while semilogx works fine I with matplotlib with python2 on RedHat 9.0 default setup Any idea of what is going wrong ? Below is the code I use in the interactive2 mode: Takk Kve=C3=B0ja Jean-Baptiste Welcome to matplotlib. help(matplotlib) -- shows a list of all matlab compatible commands provided help(plotting) -- shows a list of plot specific commands >>> import matplotlib >>> from matplotlib.matlab import * pygtk.require() must be called before importing gtk matplotlib requires pygtk-1.99.16 or greater -- trying anyway. Please hold on >>> from matplotlib.backends.backend_gtk import ShowOn >>> ShowOn().set(1) # turning on interactive mode >>> dt=3D0.01 >>> t=3Darange(dt,10.0,dt) >>> semilogy(t,t) Traceback (most recent call last): File "<<console>>", line 1, in ? File "/usr/lib/python2.2/site-packages/matplotlib/matlab.py", line 829, in semilogy try: ret =3D gca().semilogy(*args, **kwargs) File "/usr/lib/python2.2/site-packages/matplotlib/axes.py", line 2007, in semilogy l =3D selfplot(*args, **kwargs) NameError: global name 'selfplot' is not defined >>> semilogx(t,t) [<matplotlib.lines.Line2D instance at 0x8516034>] >>>=20
I want to plot semilogy with major and minor grid. I tried: plt.grid(which='both') But 2 problems: 1) For semilogy, most of my viewers will expect to see 10 minor ticks/major tick. I got 5. How do I change it? 2) I'd like the major ticks to be solid lines, and minor ticks to be dashed. I got all dashed.
Neal Becker, on 2011年01月05日 08:19, wrote: > I want to plot semilogy with major and minor grid. I tried: > > plt.grid(which='both') > > But 2 problems: > > 1) For semilogy, most of my viewers will expect to see 10 minor > ticks/major tick. I got 5. How do I change it? Hi Neal, odd, it works here. (See attached image) In [1]: plt.semilogy(((np.random.rand(50)*9+1))) If your problem persists, can you provide a small example where this does not work? You might check the minor locator - make sure that it is base 10 In [2]: plt.gca().yaxis.minor.locator._base Out[2]: 10.0 > 2) I'd like the major ticks to be solid lines, and minor ticks > to be dashed. I got all dashed. In [3]: plt.grid(which='major', linestyle='solid') In [4]: plt.grid(which='minor', linestyle='dashed') -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
Paul Ivanov wrote: > Neal Becker, on 2011年01月05日 08:19, wrote: >> I want to plot semilogy with major and minor grid. I tried: >> >> plt.grid(which='both') >> >> But 2 problems: >> >> 1) For semilogy, most of my viewers will expect to see 10 minor >> ticks/major tick. I got 5. How do I change it? > > Hi Neal, > > odd, it works here. (See attached image) > > In [1]: plt.semilogy(((np.random.rand(50)*9+1))) > > If your problem persists, can you provide a small example where > this does not work? You might check the minor locator - make > sure that it is base 10 Perhaps because my data covered a large range 10**-7 ... 10**0? I'll try some experiments. I had to force it with: fig.get_axes()[0].set_yticks ([a*(10**b) for b in xrange (-7,0) for a in xrange (1,10) ], minor=True) > In [2]: plt.gca().yaxis.minor.locator._base > Out[2]: 10.0 > >> 2) I'd like the major ticks to be solid lines, and minor ticks >> to be dashed. I got all dashed. > > In [3]: plt.grid(which='major', linestyle='solid') > In [4]: plt.grid(which='minor', linestyle='dashed') >
>>>>> "Jean-Baptiste" == Jean-Baptiste Cazier <jea...@de...> writes: It's a bug that somehow escaped our poor-man's regression testing suite. line 2007 in /usr/lib/python2.2/site-packages/matplotlib/axes.py should read l = self.plot(*args, **kwargs) ^ not l = selfplot(*args, **kwargs) Thanks for the report! JDH