[Matplotlib-users] normal x-y axes without a box

2010-11-30 Thread David Pine
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()

inline: test.pnginline: test1.png--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] normal x-y axes without a box

2010-11-30 Thread Benjamin Root
On Tue, Nov 30, 2010 at 2:49 AM, David Pine d...@nyu.edu wrote:

 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()



Dave, I believe that the axis spine feature is what you are looking for:

http://matplotlib.sourceforge.net/users/whats_new.html#axis-spine-placement

I hope that helps!
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] adding a number of minor tick marks between major tick marks feature

2010-11-30 Thread Matthias Michler
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

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [mplot3d] remove background

2010-11-30 Thread Benjamin Root
On Sun, Nov 28, 2010 at 7:48 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:

 If you want the whole background to disappear, simply call set_axis_off
 method.

 ax.set_axis_off()

 To control the visibility of each element, use something like below.

 for axis in ax.w_xaxis, ax.w_yaxis, ax.w_zaxis:
  for elt in axis.get_ticklines() + axis.get_ticklabels():
  elt.set_visible(False)

   axis.pane.set_visible(False)
  axis.gridlines.set_visible(False)
  axis.line.set_visible(False)

 IHTH,

 -JJ

 On Mon, Nov 29, 2010 at 9:08 AM, Nicolas Pinto nicolas.pi...@gmail.com
 wrote:
  Thanks for the quick reply Ben. Let me know how I can help.
 
  Regards,
 
  N
 
  On Sun, Nov 28, 2010 at 6:54 PM, Benjamin Root ben.r...@ou.edu wrote:
  On Sunday, November 28, 2010, Nicolas Pinto nicolas.pi...@gmail.com
 wrote:
  Dear all,
 
  I'm trying to get rid of the mplot3d background (in vain, see below),
  how can I do this?
 
  Thanks for your help.
 
  Best,
 
  Nicolas
 
  demo:
 
  from mpl_toolkits.mplot3d import axes3d, axis3d
  import matplotlib.pyplot as plt
  import numpy as np
 
  fig = plt.figure()
  ax = axes3d.Axes3D(fig)
 
  for axis in ax.w_xaxis, ax.w_yaxis, ax.w_zaxis:
  for elt in axis.get_ticklines() + axis.get_ticklabels():
  elt.set_visible(False)
 
  myAXINFO = {
  'x': {'i': 0, 'tickdir': 1, 'juggled': (1, 0, 2),
'color': (0, 0, 0, 0, 0)},
  'y': {'i': 1, 'tickdir': 0, 'juggled': (0, 1, 2),
'color': (0, 0, 0, 0, 0)},
  'z': {'i': 2, 'tickdir': 0, 'juggled': (0, 2, 1),
'color': (0, 0, 0, 0, 0)},
  }
 
  ax.w_xaxis._AXINFO = myAXINFO
  ax.w_yaxis._AXINFO = myAXINFO
  ax.w_zaxis._AXINFO = myAXINFO
 
  plt.show()
 
 
 --
  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@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
  Unfortunately, I doubt you will be able to in the current state of
  mplot3d's code. The background objects get remade at every change of
  viewing angle or change in the figure window.  I am working on some
  refactoring, but it will be a while before I tackle the drawing
  behavior.
 
  Let me take a look in the next couple of days on a possible workaround
 
  Ben Root
 
 
 
 
  --
  Nicolas Pinto
  Ph.D. Candidate, Brain  Computer Sciences
  Massachusetts Institute of Technology, USA
  http://web.mit.edu/pinto



Indeed, Jae-Joon is correct.  I now see why Nicolas's code did not work.
The assignment of _AXINFO occurred after the initial creation of the axes
panels.  While the code does reuse the _AXINFO data for some things in later
redraws, it does not re-use the color information.  I should also point out
that changing the _AXINFO data has the side affect of being applicable to
all future instantiations of 3D axes within that process run.  That could be
a bug or a feature, but it is something to be aware of in the future.

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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subclassing AutoDateFormatter correctly

2010-11-30 Thread C M
On Sun, Nov 28, 2010 at 8:52 PM, C M cmpyt...@gmail.com 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
--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subclassing AutoDateFormatter correctly

2010-11-30 Thread Ryan May
On Tue, Nov 30, 2010 at 10:44 AM, C M cmpyt...@gmail.com wrote:


 On Sun, Nov 28, 2010 at 8:52 PM, C M cmpyt...@gmail.com 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

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] adding a number of minor tick marks between major tick marks feature

2010-11-30 Thread Gökhan Sever
On Mon, Nov 29, 2010 at 3:01 PM, Matthew W. Priddy mwpri...@gmail.com 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

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subclassing AutoDateFormatter correctly

2010-11-30 Thread C M
On Tue, Nov 30, 2010 at 12:23 PM, Ryan May rma...@gmail.com wrote:

 On Tue, Nov 30, 2010 at 10:44 AM, C M cmpyt...@gmail.com wrote:
 
 
  On Sun, Nov 28, 2010 at 8:52 PM, C M cmpyt...@gmail.com 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.


Thanks, Ryan.  I've done that now.  I use the OOP approach to matplotlib and
embed it in wxPython, so my example uses that.  I did not know how to apply
an AutoDateFormatter to an axis if using pylab and figured the basics of
what I am trying to do are apparent from this sample.

The sample is attached.  The point of it is that, despite it apparently
using my AutoDateFormatter, all the dates at all levels of zoom are %Y (e.g.
2010).  This is because in the AutoDateFormatter subclass, the line:

scale = float( self._locator._get_unit() )

is *always* returning 365.0.

I am not bothering for now to include the business about how point-picking
remedies my problem, because the AutoDateFormatter shouldn't need
that--obviously, the way I am doing it is wrong, and I'd like to know what
it is.

Thanks for any help,
Che


plot_test.py
Description: Binary data
--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] subclassing AutoDateFormatter correctly

2010-11-30 Thread Ryan May
On Tue, Nov 30, 2010 at 7:00 PM, C M cmpyt...@gmail.com wrote:
 Thanks, Ryan.  I've done that now.  I use the OOP approach to matplotlib and
 embed it in wxPython, so my example uses that.  I did not know how to apply
 an AutoDateFormatter to an axis if using pylab and figured the basics of
 what I am trying to do are apparent from this sample.

 The sample is attached.  The point of it is that, despite it apparently
 using my AutoDateFormatter, all the dates at all levels of zoom are %Y (e.g.
 2010).  This is because in the AutoDateFormatter subclass, the line:

 scale = float( self._locator._get_unit() )

 is *always* returning 365.0.

 I am not bothering for now to include the business about how point-picking
 remedies my problem, because the AutoDateFormatter shouldn't need
 that--obviously, the way I am doing it is wrong, and I'd like to know what
 it is.

I'm guessing your problem was that only the year was being shown,
regardless? It would seem the problem stems from the fact that while
you give your formatter the AutoDateLocator, you never tell the axis
to use this. I got what I considered the correct behavior by adding
the following line at linen 84 in the script:

   self.subplot.xaxis.set_major_locator(adl)

Does adding that get you what you want?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users