On Mon, Nov 29, 2010 at 3:01 PM, Matthew W. Priddy <mwpriddy@...> wrote:
> Matplotlib developers,
>
> I really like using matplotlib to create quality plots, and it seems to have an option for just about everything. However, one thing that is not easy to change is the location of minor tick marks. To set major tick mark locations, one can simply use the "xticks" command. And now we can atleast turn on the minor tick marks with the "minorticks_on()" command.
>
> But, is there any way to implement something similar to "xticks" for minor tick marks? Even better would be a feature that allowed the user to simply specify the number of minor tick marks that are evenly spaced between the major tick marks?
>
> Thanks.
>
> --Matthew
It is easy with MultipleLocator class.
I[1]: y = np.random.randn(100)
I[2]: plt.plot(y)
O[2]: [<matplotlib.lines.Line2D object at 0xa82ea6c>]
I[3]: from matplotlib.ticker import MultipleLocator
I[4]: ax = plt.gca()
I[5]: ax.xaxis.set_minor_locator(MultipleLocator(5))
--
Gökhan

On Tue, Nov 30, 2010 at 10:44 AM, C M <cmpython@...> wrote:
>
>
> On Sun, Nov 28, 2010 at 8:52 PM, C M <cmpython@...> wrote:
>>
>> How can I correctly subclass AutoDateFormatter and use it in my code?
>>
>> What I am doing is copying the code from matplotlib's AutoDateFormatter
>> and changing the strings for how the dates are represented and making that a
>> class, MyAutoDateFormatter. AutoDateFormatter expects a locator, and I
>> think (?) the default is AutoDateLocator. So in my code I am doing this:
>>
>> adl = AutoDateLocator()
>> myformatter = MyAutoDateFormatter(adl)
>> axis.xaxis.set_major_formatter(myformatter)
>>
>> But when I run it, no matter the level of zoom, it says "2010" (when it
>> should change depending on zoom level).
>>
>> However, if I go into the matplotlib dates.py code itself and save the
>> same changes to the date strings there, and I comment out the above code,
>> then it works: the date strings change depending on level of zoom.
>
> I've also just noticed that if I use the above code after the lines have
> been plotted, but then I click on one of the points (which causes a
> point-picking routine that ultimately plots a highlighting marker over that
> point), the x axis suddenly changes to use MyAutoDateFormatter's format
> strings. (If I call it before I plot anything, it doesn't help, though).
>
> Is the act of plotting somehow "refreshing" things? What can I call in
> order to force this to happen without actually plotting any additional
> points after my lines are plotted?
It's difficult to tell without seeing the code that's producing the
problem. If you can boil your problem down to a simple, self-contained
script and post it here, then we can take a look and see what's going
on.
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

On Sun, Nov 28, 2010 at 8:52 PM, C M <cmpython@...> wrote:
> How can I correctly subclass AutoDateFormatter and use it in my code?
>
> What I am doing is copying the code from matplotlib's AutoDateFormatter and
> changing the strings for how the dates are represented and making that a
> class, MyAutoDateFormatter. AutoDateFormatter expects a locator, and I
> think (?) the default is AutoDateLocator. So in my code I am doing this:
>
> adl = AutoDateLocator()
> myformatter = MyAutoDateFormatter(adl)
> axis.xaxis.set_major_formatter(myformatter)
>
> But when I run it, no matter the level of zoom, it says "2010" (when it
> should change depending on zoom level).
>
> However, if I go into the matplotlib dates.py code itself and save the same
> changes to the date strings there, and I comment out the above code, then it
> works: the date strings change depending on level of zoom.
>
I've also just noticed that if I use the above code after the lines have
been plotted, but then I click on one of the points (which causes a
point-picking routine that ultimately plots a highlighting marker over that
point), the x axis suddenly changes to use MyAutoDateFormatter's format
strings. (If I call it before I plot anything, it doesn't help, though).
Is the act of plotting somehow "refreshing" things? What can I call in
order to force this to happen without actually plotting any additional
points after my lines are plotted?
Thanks,
Che

On Monday November 29 2010 22:01:29 Matthew W. Priddy wrote:
> Matplotlib developers,
>
> I really like using matplotlib to create quality plots, and it seems to
> have an option for just about everything. However, one thing that is not
> easy to change is the location of minor tick marks. To set major tick
> mark locations, one can simply use the "xticks" command. And now we can
> atleast turn on the minor tick marks with the "minorticks_on()" command.
>
> But, is there any way to implement something similar to "xticks" for minor
> tick marks? Even better would be a feature that allowed the user to
> simply specify the number of minor tick marks that are evenly spaced
> between the major tick marks?
Hi Matthew,
one thing, which should work is the following. If you want to set the
positions of minor ticks of an axes 'ax', you can use
ax.set_xticks([0.02, 0.04, 0.06, 0.08, 0.1], minor=True)
but I'm not an expert and I'm not sure if something like you mentioned is
already supported (namely providing the number of minor tick marks).
Kind regards,
Matthias

Is there a simple way to make a plot with axes that look like those in test1.png rather than like those in test.png? Here is the code that produced test.png. Thanks.
Dave Pine
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0., 20., 100)
y = np.sin(t)
fig = plt.figure(1, figsize=(6,3) )
fig.subplots_adjust(bottom=0.2)
ax = fig.add_subplot(1,1,1)
ax.plot(t, y)
ax.set_xlabel('t')
ax.set_ylabel('y')
plt.savefig('test.png')
plt.show()

On Mon, Nov 29, 2010 at 1:48 PM, Massimo Di Stefano <
massimodisasha@...> wrote:
> Hello All,
>
> i'm tring to write python code to display images from a directory .. but
> i'm not able to learn how to use the matplotlib events
> to handle how the images will be displaied.
>
> simpli i need to pass to the code the path to directory where i have
> several tiff files and disply them one at time using a key event.
>
> to display a single image i'm using somethin like :
>
>
>
> #!/usr/bin/env python
> from pylab import *
> try:
> import Image
> except ImportError, exc:
> raise SystemExit("PIL must be installed to run this example")
> import glob
>
> def dispimg(input):
> image = Image.open(input)
> im = imshow(image, origin='lower')
> show()
>
>
>
> ###########
>
> i tried to define a key action like :
>
>
> def onpress(event):
> if event.key=='a':
> fig.canvas.draw()
>
>
> # and set my directory with :
>
> fig = figure()
> fig.canvas.mpl_connect('key_press_event', onpress)
> TIFFS = glob.glob("/home/habcam/habcamdata/20100820_1840/*.tif")
> print "num TIFFS %d" % len(TIFFS)
>
> ##############
>
> but i'm not able to learn how to plot them and update the displayed image
> using the key bindings :
>
> for tif in TIFFS:
> print tif
> show()
>
>
> thanks a lot for Any help!
>
>
> Massimo.
>
Massimo,
You might want to try a different approach. Instead of having a keypress
binding, why not just have a normal for-loop with a call to dispimg() and
some sort of blocking input like a wait for keypress or something? You
might even be able to do something with a while loop that checks for a 'q'
input (for quit) and then have two keys be used for forward and backwards
progression through your list of TIFFS.
Another thing to consider is just not use matplotlib at all, and just use
linux's image viewer (called "eog") which you can give it the first file in
a directory, and you can use the arrow keys to move through the list of all
image files in that directory.
I hope that helps,
Ben Root

Matplotlib developers,
I really like using matplotlib to create quality plots, and it seems to have an option for just about everything. However, one thing that is not easy to change is the location of minor tick marks. To set major tick mark locations, one can simply use the "xticks" command. And now we can atleast turn on the minor tick marks with the "minorticks_on()" command.
But, is there any way to implement something similar to "xticks" for minor tick marks? Even better would be a feature that allowed the user to simply specify the number of minor tick marks that are evenly spaced between the major tick marks?
Thanks.
--Matthew

Hello All,
i'm tring to write python code to display images from a directory .. but i'm not able to learn how to use the matplotlib events
to handle how the images will be displaied.
simpli i need to pass to the code the path to directory where i have several tiff files and disply them one at time using a key event.
to display a single image i'm using somethin like :
#!/usr/bin/env python
from pylab import *
try:
import Image
except ImportError, exc:
raise SystemExit("PIL must be installed to run this example")
import glob
def dispimg(input):
image = Image.open(input)
im = imshow(image, origin='lower')
show()
###########
i tried to define a key action like :
def onpress(event):
if event.key=='a':
fig.canvas.draw()
# and set my directory with :
fig = figure()
fig.canvas.mpl_connect('key_press_event', onpress)
TIFFS = glob.glob("/home/habcam/habcamdata/20100820_1840/*.tif")
print "num TIFFS %d" % len(TIFFS)
##############
but i'm not able to learn how to plot them and update the displayed image using the key bindings :
for tif in TIFFS:
print tif
show()
thanks a lot for Any help!
Massimo.

On 11/29/2010 10:52 AM, Daniel Hyams wrote:
> Just out of curiosity, is anyone using the fontconfig way of mapping
> fonts? I turned it on one day, but the immediate problem was that no
> mathtext worked any more; so I turned it back off. Any mathtext in
> titles, labels, etc. just rendered as a much of seemingly random letters.
That's one of the drawbacks of the fontconfig mode -- probably the main
reason it isn't turned on by default. fontconfig only looks in
system-standard locations for fonts (by default), and matplotlib
installs its special math fonts in a different place. fontconfig
provides a C-level API to add another search directory, but it would
have to be wrapped for Python.
>
> And I'll tack a second question in here as well; the reason that I was
> playing with fontconfig is that the font cache takes a really long
> time to build in certain circumstances (I'm having trouble identifying
> exactly when)....so I guess the question is...has anyone else seen
> this? For example, on my (2008 vintage) mac mini, a complete rebuild
> of the font cache takes around 3 seconds, which is fine. On a macbook
> pro (tested on three different machines so far), it takes 30 seconds.
> This makes no sense at all to me, so any insights welcome :)
It's dependent on a) how many fonts you have installed and b) the
performance of the file system they are on. On my Linux machine with a
number of network shares involved, it can take a very long time.
>
> I initially thought that perhaps the other users had a ton more fonts
> than I, but I don't think so...if I remember correctly, their font
> cache on the macbook pro ended up being smaller than mine on the mini.
It's hard to say what might be causing this.
However, why are you concerned about it, since the cache only has to be
built once? (After all, that is the point of an on-disk font cache in
the first place...)
Mike
>
>
> On Mon, Nov 29, 2010 at 10:10 AM, Michael Droettboom <mdroe@...
> <mailto:mdroe@...>> wrote:
>
> The fontManager is essentially a replacement for what fontconfig
> provides on many platforms -- so it's intended that the fontManager
> doesn't exist if the user opts to use fontconfig. However, that's
> still
> an "experimental" option because it hasn't been formally tested on
> many
> platforms, and, as you point out, there may still be code paths that
> aren't coded correctly for that option.
>
> Mike
>
> On 11/25/2010 10:34 AM, Benjamin Root wrote:
> > On Wednesday, November 24, 2010, Daniel Hyams<dhyams@...
> <mailto:dhyams@...>> wrote:
> >> MPL 1.0.0, OSX
> >> If USE_FONTCONFIG is turned on, the function
> FontProperties.get_size_in_points will sometimes fail, because it
> is wanting to use "fontManager", which is still 'None' if
> USE_FONTCONFIG is on. I'm not sure if it's the proper way to fix
> it, but here is a small patch that works (meaning that at least
> the code doesn't die; I can't vouch for much else):
> >>
> >>
> >> ORIGINAL:
> >> def get_size_in_points(self): if self._size is not
> None: try: return float(self._size)
> >>
> >> except ValueError: pass
> default_size = fontManager.get_default_size() return
> default_size * font_scalings.get(self._size)
> >>
> >>
> >> NEW:
> >> def get_size_in_points(self): if self._size is not
> None: try: return float(self._size)
> except ValueError:
> >>
> >> pass if fontManager:
> default_size = fontManager.get_default_size() else:
> default_size = rcParams['font.size']
> >>
> >> return default_size * font_scalings.get(self._size)
> >>
> >> --
> >> Daniel Hyams
> >> dhyams@... <mailto:dhyams@...>
> >>
> >>
> > I personally think that this is reasonable, as it guarantees a size
> > value to come from somewhere. However, I am concerned about
> > fontManager being None. If it isn't a bug for it to be None at this
> > point, then I have to wonder where-else in the code needs a
> check for
> > None? If it is a bug, then what should it be when USE_FONTCONFIG is
> > true?
> >
> > Good catch Daniel.
> >
> > Ben Root
> >
> >
> ------------------------------------------------------------------------------
> > Increase Visibility of Your 3D Game App& Earn a Chance To Win $500!
> > Tap into the largest installed PC base& get more eyes on your
> game by
> > optimizing for Intel(R) Graphics Technology. Get started today
> with the
> > Intel(R) Software Partner Program. Five $500 cash prizes are up
> for grabs.
> > http://p.sf.net/sfu/intelisp-dev2dev
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users@...
> <mailto:Matplotlib-users@...>
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today
> with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up
> for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> <mailto:Matplotlib-users@...>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> --
> Daniel Hyams
> dhyams@... <mailto:dhyams@...>
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App& Earn a Chance To Win $500!
> Tap into the largest installed PC base& get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Just out of curiosity, is anyone using the fontconfig way of mapping fonts?
I turned it on one day, but the immediate problem was that no mathtext
worked any more; so I turned it back off. Any mathtext in titles, labels,
etc. just rendered as a much of seemingly random letters.
And I'll tack a second question in here as well; the reason that I was
playing with fontconfig is that the font cache takes a really long time to
build in certain circumstances (I'm having trouble identifying exactly
when)....so I guess the question is...has anyone else seen this? For
example, on my (2008 vintage) mac mini, a complete rebuild of the font cache
takes around 3 seconds, which is fine. On a macbook pro (tested on three
different machines so far), it takes 30 seconds. This makes no sense at all
to me, so any insights welcome :)
I initially thought that perhaps the other users had a ton more fonts than
I, but I don't think so...if I remember correctly, their font cache on the
macbook pro ended up being smaller than mine on the mini.
On Mon, Nov 29, 2010 at 10:10 AM, Michael Droettboom <mdroe@...>wrote:
> The fontManager is essentially a replacement for what fontconfig
> provides on many platforms -- so it's intended that the fontManager
> doesn't exist if the user opts to use fontconfig. However, that's still
> an "experimental" option because it hasn't been formally tested on many
> platforms, and, as you point out, there may still be code paths that
> aren't coded correctly for that option.
>
> Mike
>
> On 11/25/2010 10:34 AM, Benjamin Root wrote:
> > On Wednesday, November 24, 2010, Daniel Hyams<dhyams@...> wrote:
> >> MPL 1.0.0, OSX
> >> If USE_FONTCONFIG is turned on, the function
> FontProperties.get_size_in_points will sometimes fail, because it is wanting
> to use "fontManager", which is still 'None' if USE_FONTCONFIG is on. I'm
> not sure if it's the proper way to fix it, but here is a small patch that
> works (meaning that at least the code doesn't die; I can't vouch for much
> else):
> >>
> >>
> >> ORIGINAL:
> >> def get_size_in_points(self): if self._size is not None:
> try: return float(self._size)
> >>
> >> except ValueError: pass default_size
> = fontManager.get_default_size() return default_size *
> font_scalings.get(self._size)
> >>
> >>
> >> NEW:
> >> def get_size_in_points(self): if self._size is not None:
> try: return float(self._size) except
> ValueError:
> >>
> >> pass if fontManager: default_size =
> fontManager.get_default_size() else: default_size =
> rcParams['font.size']
> >>
> >> return default_size * font_scalings.get(self._size)
> >>
> >> --
> >> Daniel Hyams
> >> dhyams@...
> >>
> >>
> > I personally think that this is reasonable, as it guarantees a size
> > value to come from somewhere. However, I am concerned about
> > fontManager being None. If it isn't a bug for it to be None at this
> > point, then I have to wonder where-else in the code needs a check for
> > None? If it is a bug, then what should it be when USE_FONTCONFIG is
> > true?
> >
> > Good catch Daniel.
> >
> > Ben Root
> >
> >
> ------------------------------------------------------------------------------
> > Increase Visibility of Your 3D Game App& Earn a Chance To Win $500!
> > Tap into the largest installed PC base& get more eyes on your game by
> > optimizing for Intel(R) Graphics Technology. Get started today with the
> > Intel(R) Software Partner Program. Five $500 cash prizes are up for
> grabs.
> > http://p.sf.net/sfu/intelisp-dev2dev
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users@...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
> Tap into the largest installed PC base & get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Daniel Hyams
dhyams@...

The fontManager is essentially a replacement for what fontconfig
provides on many platforms -- so it's intended that the fontManager
doesn't exist if the user opts to use fontconfig. However, that's still
an "experimental" option because it hasn't been formally tested on many
platforms, and, as you point out, there may still be code paths that
aren't coded correctly for that option.
Mike
On 11/25/2010 10:34 AM, Benjamin Root wrote:
> On Wednesday, November 24, 2010, Daniel Hyams<dhyams@...> wrote:
>> MPL 1.0.0, OSX
>> If USE_FONTCONFIG is turned on, the function FontProperties.get_size_in_points will sometimes fail, because it is wanting to use "fontManager", which is still 'None' if USE_FONTCONFIG is on. I'm not sure if it's the proper way to fix it, but here is a small patch that works (meaning that at least the code doesn't die; I can't vouch for much else):
>>
>>
>> ORIGINAL:
>> def get_size_in_points(self): if self._size is not None: try: return float(self._size)
>>
>> except ValueError: pass default_size = fontManager.get_default_size() return default_size * font_scalings.get(self._size)
>>
>>
>> NEW:
>> def get_size_in_points(self): if self._size is not None: try: return float(self._size) except ValueError:
>>
>> pass if fontManager: default_size = fontManager.get_default_size() else: default_size = rcParams['font.size']
>>
>> return default_size * font_scalings.get(self._size)
>>
>> --
>> Daniel Hyams
>> dhyams@...
>>
>>
> I personally think that this is reasonable, as it guarantees a size
> value to come from somewhere. However, I am concerned about
> fontManager being None. If it isn't a bug for it to be None at this
> point, then I have to wonder where-else in the code needs a check for
> None? If it is a bug, then what should it be when USE_FONTCONFIG is
> true?
>
> Good catch Daniel.
>
> Ben Root
>
> ------------------------------------------------------------------------------
> Increase Visibility of Your 3D Game App& Earn a Chance To Win $500!
> Tap into the largest installed PC base& get more eyes on your game by
> optimizing for Intel(R) Graphics Technology. Get started today with the
> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
> http://p.sf.net/sfu/intelisp-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi,
I am trying to produce a pcolor figure with a black background using
pylab.figure(facecolor = 'black')
Consequently, I need to change the tick colors and xlabel and ylabel
colors to white using
pylab.xlabel('whatever is on the xlabel', color = 'white', fontsize
= 14)
pylab.ylabel('whatever is on the ylabel', color = 'white', fontsize
= 14)
pylab.yticks(color = 'white')
pylab.xticks(color = 'white')
Up to this point, everything is OK. The next thing I need to do is
change the colors of the ticks and the ticklabels in the colorbar. I
understand that there are no simple pylab. commands which do so. I saw
in some matplotlib-users messages that one can write the following to
change the fontsize, for example:
for t in cb.ax.get_yticklabels():
t.set_fontsize(14)
I tried adding another line to this loop:
t.set_color('white')
On one hand, there is no error message during parsing or compilation. On
the other hand, nothing actually changes, i.e. the color of the
ticklabels and ticks stays black.
How does one change this property?
Amit

How can I correctly subclass AutoDateFormatter and use it in my code?
What I am doing is copying the code from matplotlib's AutoDateFormatter and
changing the strings for how the dates are represented and making that a
class, MyAutoDateFormatter. AutoDateFormatter expects a locator, and I
think (?) the default is AutoDateLocator. So in my code I am doing this:
adl = AutoDateLocator()
myformatter = MyAutoDateFormatter(adl)
axis.xaxis.set_major_formatter(myformatter)
But when I run it, no matter the level of zoom, it says "2010" (when it
should change depending on zoom level).
However, if I go into the matplotlib dates.py code itself and save the same
changes to the date strings there, and I comment out the above code, then it
works: the date strings change depending on level of zoom.
I could just leave it changed in mpl's dates.py module, but I'd rather
subclass AutoDateFormatter so that if I share the source code of my app with
others, it will get this right.
What am I doing wrong?
Thanks, and any help appreciated as always.
Che

On 11/26/2010 2:28 AM, Fred Pollard wrote:
> Hi,
> I'm trying to install matplotlib on a windows machine at work to try and
> demonstrate its usefulness. I have Python 2.6 installed and managed to
> use the numpy binary install without admin priviledges.
> The matplotlib binary installer, however, requires admin priviledges,
> and I don't understand why - is an alternative installer available,
> because otherwise, I'll have to drop matplotlib and Python for somethign
> else, as IT will take a month or two to install it for me.
> I know I could build it myself, but the same restrictions are causing
> problems getting the pre-requisites installed!
> Cheers,
> Fred
>
>
The matplotlib installers for Windows are executable ZIP files generated
by Python's builtin distutils package with the
--user-access-control=auto option. See the following links for previous
discussions and a workaround for your problem.
<http://sourceforge.net/tracker/?func=detail&aid=2858636&group_id=80706&atid=560720&gt;
<http://www.mail-archive.com/matplotlib-users@.../msg17728.html&gt;
<http://www.mail-archive.com/matplotlib-users@.../msg13466.html&gt;
Christoph

On Friday, November 26, 2010, Fred Pollard <fred.pollard@...> wrote:
> Hi,
>
> I'm trying to install matplotlib on a windows machine at work to try and demonstrate its usefulness. I have Python 2.6 installed and managed to use the numpy binary install without admin priviledges.
>
> The matplotlib binary installer, however, requires admin priviledges, and I don't understand why - is an alternative installer available, because otherwise, I'll have to drop matplotlib and Python for somethign else, as IT will take a month or two to install it for me.
>
>
> I know I could build it myself, but the same restrictions are causing problems getting the pre-requisites installed!
>
> Cheers,
> Fred
>
Fred
I have not tried installing mpl on windows, but when building on
Linux, I can pass the --user option in the command-line to setupegg.py
to do a local build and install. Maybe the same is available on
Windows?
Ben Root