missing ticks on inverted log axis

Hi, I am having troubles to correctly make a figure with inverted log axis.
This is what I am doing:

import numpy as np
import matplotlib.pyplot as plt

y=np.linspace(-90,90,20)
z=np.arange(1,1.e4, 200)

c=y.reshape(20,1)*z.reshape(1,len(z))

fig,ax=plt.subplots()
plt.pcolor(y,z,c.transpose())
ax.set_yscale('log')
ax.invert_yaxis()

The problem is that the ticks of y axis is not displayed correctly once I
invert the y axis. It shows the tick at 1000. All other ticks such as 100,
10 and 1 are missing. Am I doing something wrong or is this a bug in
matplotlib?

Thanks for your help.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

This works fine on my system:
In [3]: np.version.full_version

Out[3]: '1.7.1'

In [5]: matplotlib.__version__

Out[5]: '1.2.1'

Not sure what the issue could be.

-p

···

On Wed, May 15, 2013 at 3:48 PM, gaspra <yes2sky@...287...> wrote:

Hi, I am having troubles to correctly make a figure with inverted log axis.
This is what I am doing:

import numpy as np
import matplotlib.pyplot as plt

y=np.linspace(-90,90,20)
z=np.arange(1,1.e4, 200)

c=y.reshape(20,1)*z.reshape(1,len(z))

fig,ax=plt.subplots()
plt.pcolor(y,z,c.transpose())
ax.set_yscale('log')
ax.invert_yaxis()

The problem is that the ticks of y axis is not displayed correctly once I
invert the y axis. It shows the tick at 1000. All other ticks such as 100,
10 and 1 are missing. Am I doing something wrong or is this a bug in
matplotlib?

Thanks for your help.

Paul Hobson-2 wrote

This works fine on my system:
In [3]: np.version.full_version

Out[3]: '1.7.1'

In [5]: matplotlib.__version__

Out[5]: '1.2.1'

Not sure what the issue could be.

-p

Hi Paul,

Thanks for the reply. I am using np version 1.7.1 and matplotlib version
1.3.x. In fact I have the same problem with matplotlib version 1.2.1. Could
it be the problem with Mac OS (mountain lion 10.8.3)?

Yuan

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41065.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I find the issue came from the matplotlib backend. The problem is gone when
using TkAgg backend. However, TkAgg doesn't work with matplotlib 1.3.x,
which has some conflict of Tk dynamic library due to different Tk version,
i.e., macports uses Tk8.6 and Mac OSX 10.8.3 uses Tk8.5.

I really need the "tri" package in matplotlib 1.3.x. Is there anyway I can
manually replace the "tri" package in matplotlib 1.2.0 (installed by
macports) with the one in matplotlib 1.3.x (downloaded from the latest
master in github repository?

Thanks.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41084.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I find the issue came from the matplotlib backend. The problem is gone when
using TkAgg backend. However, TkAgg doesn't work with matplotlib 1.3.x,
which has some conflict of Tk dynamic library due to different Tk version,
i.e., macports uses Tk8.6 and Mac OSX 10.8.3 uses Tk8.5.

If you use the macports version of Python, this shouldn't be a problem. I think the problem is (perhaps) that you're trying to use the system Python with packages from MacPorts?

I really need the "tri" package in matplotlib 1.3.x. Is there anyway I can
manually replace the "tri" package in matplotlib 1.2.0 (installed by
macports) with the one in matplotlib 1.3.x (downloaded from the latest
master in github repository?

Possible, but probably not straightforward. I would try to tackle the environmental problem above first.

Mike

···

On 05/18/2013 04:17 AM, gaspra wrote:

Thanks.

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41084.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Michael Droettboom-3 wrote

If you use the macports version of Python, this shouldn't be a problem.
I think the problem is (perhaps) that you're trying to use the system
Python with packages from MacPorts?

Yes, I can confirm the system Python doesn't work with TkAgg and
matplotlib 1.3.x. The problem with matplotlib 1.3.x and Macports Python
is that the Tk/Tcl library used in setupext.py is hardwired to system Tk/Tcl
for Mac platform. Here is the piece of code from setupext.py:

elif sys.platform == 'darwin':
            # this config section lifted directly from Imaging - thanks to
            # the effbot!

            # First test for a MacOSX/darwin framework install
            from os.path import join, exists
            framework_dirs = [
                join(os.getenv('HOME'), '/Library/Frameworks'),
                '/Library/Frameworks',
                '/System/Library/Frameworks/',
            ]

Therefore matplotlib 1.3.x is compiled with system Tk/Tcl regardless which
python is used (macports or system). I have tried to hardwire the macports
Tk dynamic library but there are errors when importing matplotlib in python.
It would be great if the devs can modify the setupext.py to use macports
Tk/Tcl
libraries properly, e.g., enabling a choice for using system or macports
Tk/Tcl
libraries.

Michael Droettboom-3 wrote

I really need the "tri" package in matplotlib 1.3.x. Is there anyway I
can
manually replace the "tri" package in matplotlib 1.2.0 (installed by
macports) with the one in matplotlib 1.3.x (downloaded from the latest
master in github repository?

Possible, but probably not straightforward. I would try to tackle the
environmental problem above first.

I guess I will just modify the codes in "tri" package so I can use them as
standalone modules.

Thanks.
Yuan

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41086.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I have created https://github.com/matplotlib/matplotlib/issues/2025 to track this.

···

On 05/19/2013 05:18 PM, gaspra wrote:

Michael Droettboom-3 wrote

If you use the macports version of Python, this shouldn't be a problem.
I think the problem is (perhaps) that you're trying to use the system
Python with packages from MacPorts?

Yes, I can confirm the system Python doesn't work with TkAgg and
matplotlib 1.3.x. The problem with matplotlib 1.3.x and Macports Python
is that the Tk/Tcl library used in setupext.py is hardwired to system Tk/Tcl
for Mac platform. Here is the piece of code from setupext.py:

elif sys.platform == 'darwin':
             # this config section lifted directly from Imaging - thanks to
             # the effbot!

             # First test for a MacOSX/darwin framework install
             from os.path import join, exists
             framework_dirs = [
                 join(os.getenv('HOME'), '/Library/Frameworks'),
                 '/Library/Frameworks',
                 '/System/Library/Frameworks/',
             ]

Therefore matplotlib 1.3.x is compiled with system Tk/Tcl regardless which
python is used (macports or system). I have tried to hardwire the macports
Tk dynamic library but there are errors when importing matplotlib in python.
It would be great if the devs can modify the setupext.py to use macports
Tk/Tcl
libraries properly, e.g., enabling a choice for using system or macports
Tk/Tcl
libraries.

Michael Droettboom-3 wrote

I really need the "tri" package in matplotlib 1.3.x. Is there anyway I
can
manually replace the "tri" package in matplotlib 1.2.0 (installed by
macports) with the one in matplotlib 1.3.x (downloaded from the latest
master in github repository?

Possible, but probably not straightforward. I would try to tackle the
environmental problem above first.

I guess I will just modify the codes in "tri" package so I can use them as
standalone modules.

Thanks.
Yuan

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41086.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Michael Droettboom-3 wrote

I have created https://github.com/matplotlib/matplotlib/issues/2025 to
track this.

Hi Michael, thanks. I am somewhat convinced the problem is related to
matplotlib 1.3.x, not the Tk library. I tried on Linux that uses Tk8.5 and I
got the missing ticks for inverted log axes as well. So the TkAgg backend
only works properly with matplotlib 1.2.0.

I further tested macports python, matplotlib 1.3.x and system Tk 8.5 on Mac.
I did so by uninstalling macports version of Tk/Tcl (8.6). The ticks are
also missing.

Additional test on gtkagg backend shows the same thing: matplotlib 1.2.0
works perfectly fine with gtkagg, while matplotlib 1.3.x has the missing
ticks.

Probably you have a better sense on what is going on?

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41095.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

The issue I filed was related to the build problem you reported -- that building matplotlib with a MacPorts python is trying to use the system (framework) Tcl/Tk. That's completely independent of the other problem related to ticks, which should not be affected by the backend at all. In my quick skimming of this thread, I thought that that issue was resolved, but apparently not. I'll look into that further and file a separate issue for that if need be.

Mike

···

On 05/20/2013 06:42 PM, gaspra wrote:

Michael Droettboom-3 wrote

I have created https://github.com/matplotlib/matplotlib/issues/2025 to
track this.

Hi Michael, thanks. I am somewhat convinced the problem is related to
matplotlib 1.3.x, not the Tk library. I tried on Linux that uses Tk8.5 and I
got the missing ticks for inverted log axes as well. So the TkAgg backend
only works properly with matplotlib 1.2.0.

I further tested macports python, matplotlib 1.3.x and system Tk 8.5 on Mac.
I did so by uninstalling macports version of Tk/Tcl (8.6). The ticks are
also missing.

Additional test on gtkagg backend shows the same thing: matplotlib 1.2.0
works perfectly fine with gtkagg, while matplotlib 1.3.x has the missing
ticks.

Probably you have a better sense on what is going on?

I have opened an issue (with a fix) here:

https://github.com/matplotlib/matplotlib/pull/2036

Gregorio: Could you please confirm that the patch there addresses your original problem?

Mike

···

On 05/21/2013 08:54 AM, Michael Droettboom wrote:

On 05/20/2013 06:42 PM, gaspra wrote:

Michael Droettboom-3 wrote

I have created https://github.com/matplotlib/matplotlib/issues/2025 to
track this.

Hi Michael, thanks. I am somewhat convinced the problem is related to
matplotlib 1.3.x, not the Tk library. I tried on Linux that uses Tk8.5 and I
got the missing ticks for inverted log axes as well. So the TkAgg backend
only works properly with matplotlib 1.2.0.

I further tested macports python, matplotlib 1.3.x and system Tk 8.5 on Mac.
I did so by uninstalling macports version of Tk/Tcl (8.6). The ticks are
also missing.

Additional test on gtkagg backend shows the same thing: matplotlib 1.2.0
works perfectly fine with gtkagg, while matplotlib 1.3.x has the missing
ticks.

Probably you have a better sense on what is going on?

The issue I filed was related to the build problem you reported -- that
building matplotlib with a MacPorts python is trying to use the system
(framework) Tcl/Tk. That's completely independent of the other problem
related to ticks, which should not be affected by the backend at all.
In my quick skimming of this thread, I thought that that issue was
resolved, but apparently not. I'll look into that further and file a
separate issue for that if need be.

Mike

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Michael Droettboom-3 wrote

I have opened an issue (with a fix) here:

https://github.com/matplotlib/matplotlib/pull/2036

Awesome, this solved the problem I encountered.

Many thanks,
Yuan

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41099.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Michael Droettboom-3 wrote

Michael Droettboom-3 wrote
The issue I filed was related to the build problem you reported -- that
building matplotlib with a MacPorts python is trying to use the system
(framework) Tcl/Tk. That's completely independent of the other problem
related to ticks, which should not be affected by the backend at all.
In my quick skimming of this thread, I thought that that issue was
resolved, but apparently not. I'll look into that further and file a
separate issue for that if need be.

I have experimented the setupext.py a little bit and find this change can
compile matplotlib using MacPorts python and Tcl/Tk without conflict:

    def parse_tcl_config(self, tcl_lib_dir, tk_lib_dir):
        ...
        tcl_poss = [tcl_lib_dir,
                    os.path.normpath(os.path.join(tcl_lib_dir, '..')),
                    "/usr/lib/tcl" + str(Tkinter.TclVersion),
                    "/opt/local/lib"] # /usr/lib is replaced by
/opt/local/lib
        tk_poss = [tk_lib_dir,
                    os.path.normpath(os.path.join(tk_lib_dir, '..')),
                   "/usr/lib/tk" + str(Tkinter.TkVersion),
                   "/opt/local/lib"] # /usr/lib is replaced by
/opt/local/lib
        ...

I also replaced this logical statement:
       elif sys.platform == 'darwin':
by
       elif sys.platform == 'dummy':

The reason why I replaced /usr/lib with /opt/local/lib instead of expanding
the
tcl_poss and tk_poss lists is that the system tclConfig.sh and tkConfig.sh
are
located in /usr/lib, while the MacPorts tclConfig.sh and tkConfig.sh are
located
in /opt/local/lib.

I don't think we really need specially treatment for Mac OS, since
tclConfig.sh and
tkConfig.sh will return correctly Tcl/Tk lib/include path. Maybe I am
missing something?

I have tested this and it works perfectly fine. Surely this assumes the
MacPorts Tcl/Tk are installed. Conditions need to be added so they can check
wether
we are using MacPorts Python, wether MacPorts Tcl/Tk exist if using MacPorts
Python.
If MacPorts Tcl/Tk exist then we use /opt/local/lib, otherwise we use
/usr/lib.

Hope this helps. Thanks.

Yuan

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/missing-ticks-on-inverted-log-axis-tp41063p41100.html
Sent from the matplotlib - users mailing list archive at Nabble.com.