Re: [Matplotlib-users] Graph

2010-10-08 Thread Waléria Antunes David
I don't understand what you did, i'm reading error data from a file.

def gera_grafico(N=200, eps=1):

x = np.abs(np.random.randn(N))
y = 10*np.log((30*x + 1.)**(0.5)) + 34 + eps * np.random.randn(N)
yerr = eps * np.random.randn(N)

I don't understand what you did in this code

??

Thanks,
Waleria.


On Thu, Oct 7, 2010 at 5:06 PM, Tony S Yu  wrote:

>
> On Oct 7, 2010, at 3:38 PM, Waléria Antunes David wrote:
>
> Hi,
>
> I did like the links below, but seeing as it was my chart.
>
> See
>
> My code: http://pastebin.com/KcjHAPLN
>
> On Thu, Oct 7, 2010 at 3:08 PM, John Hunter  wrote:
>
>> On Thu, Oct 7, 2010 at 1:01 PM, Waléria Antunes David
>>  wrote:
>> > I need to know how do these vertical lines on the graph. See the
>> picture,
>> > the lines circled.
>>
>> We call these major and minor ticks.  The major ticks are the taller
>> ones, the minor ticks are the smaller ones.  Their location is
>> controlled by the major and minor Locator instances, and the text
>> printed beside them is controlled by the major and minor formatter.
>>
>> See
>>
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html
>>
>> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html
>>
>> and
>>
>>  http://matplotlib.sourceforge.net/search.html?q=codex+set_minor_locator
>>
>> To control the tick properties themselves, see the Tick section in
>>
>>  http://matplotlib.sourceforge.net/users/artists.html
>>
>> JDH
>>
>
> 
>
>
> As John mentioned, the major and minor ticks were the taller and shorter
> ticks, respectively. In your pasted example, you only change the minor
> ticks; by setting the majorLocator to same value as in the original example
> (i.e. 20), you only get the major tick at 0 because your data only goes to
> 1.5 (i.e. 20 is outside your plot range).
>
> Also, the majorFormatter in the example is set to work with integers, but
> your major tick labels should be float values (since most of them are
> between 0 and 1). Thus, the majorFormatter code is unnecessary (commented
> out below).
>
> Finally, a pet peeve: when posting example code, please make the effort to
> generate data for the plot so that others can easily run the code (see
> attached).
>
> -Tony
>
> #---
>
> import numpy as np
> import matplotlib.pyplot as plt
> from matplotlib.ticker import MultipleLocator, FormatStrFormatter
>
> def gera_grafico(N=200, eps=1):
>
> x = np.abs(np.random.randn(N))
> y = 10*np.log((30*x + 1.)**(0.5)) + 34 + eps * np.random.randn(N)
> yerr = eps * np.random.randn(N)
>
> majorLocator   = MultipleLocator(0.2)
> # majorFormatter = FormatStrFormatter('%d')
> minorLocator   = MultipleLocator(0.02)
>
> fig, ax = plt.subplots()
> plt.errorbar(x, y, yerr, fmt='ob', label='date')
>
> plt.xlim(0.0, 1.5)
> #plt.xscale('log')
> #grid(True)
>
> ax.xaxis.set_major_locator(majorLocator)
> # ax.xaxis.set_major_formatter(majorFormatter)
>
> ax.xaxis.set_minor_locator(minorLocator)
>
> return fig
>
> if __name__ == '__main__':
> gera_grafico()
> plt.show()
>
>
>
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ellipk

2010-10-08 Thread Pau
Hi,

I am trying to calculate a function with a complete elliptic integral
of the 1st kind

I have defined

Phase = 4.*sqrt(p/(p -6. - 2.*e)) * ellipk(-4.*e/(p - 6. -2.*e))

where

a_mpc = 4.0

p = a_mpc * (1 - e**2.)

and I have of course done this

#!/usr/bin/env python
from pylab import *

But when calling the script, I get:

NameError: name 'ellipk' is not defined

What am I doing wrong? Any help will be very much appreciated.

Thanks a lot,

Pau

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ellipk

2010-10-08 Thread Sebastian Busch
hey pau,

ellipk is in scipy.special:

#!/usr/bin/env python
from pylab import *
from scipy.special import ellipk

e=1.
a_mpc = 4.0
p = a_mpc * (1 - e**2.)
Phase = 4.*sqrt(p/(p -6. - 2.*e)) * ellipk(-4.*e/(p - 6. -2.*e))


greetings,
sebastian.



signature.asc
Description: OpenPGP digital signature
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Graph

2010-10-08 Thread Tony S Yu

On Oct 8, 2010, at 6:52 AM, Waléria Antunes David wrote:

> I don't understand what you did, i'm reading error data from a file.
> 
> def gera_grafico(N=200, eps=1):
> 
> x = np.abs(np.random.randn(N))
> y = 10*np.log((30*x + 1.)**(0.5)) + 34 + eps * np.random.randn(N)
> yerr = eps * np.random.randn(N)
> 
> I don't understand what you did in this code
> 
> ??
> 
> Thanks,
> Waleria.

Hey Waleria,

That was just some code to make up fake data with roughly the same shape and 
range as the data you plotted. As I mentioned, I needed to put something there 
to run your code.

Where do you get an error? If it's from the code above, you can just replace it 
with your data. In any case, you don't need to use the code I pasted; just make 
the changes I suggested: Fix the number passed to majorLocator and remove (or 
fix the initialization of) majorFormatter.

-T

> 
> 
> On Thu, Oct 7, 2010 at 5:06 PM, Tony S Yu  wrote:
> 
> On Oct 7, 2010, at 3:38 PM, Waléria Antunes David wrote:
> 
>> Hi,
>> 
>> I did like the links below, but seeing as it was my chart.
>> 
>> See
>> 
>> My code: http://pastebin.com/KcjHAPLN
>> 
>> On Thu, Oct 7, 2010 at 3:08 PM, John Hunter  wrote:
>> On Thu, Oct 7, 2010 at 1:01 PM, Waléria Antunes David
>>  wrote:
>> > I need to know how do these vertical lines on the graph. See the picture,
>> > the lines circled.
>> 
>> We call these major and minor ticks.  The major ticks are the taller
>> ones, the minor ticks are the smaller ones.  Their location is
>> controlled by the major and minor Locator instances, and the text
>> printed beside them is controlled by the major and minor formatter.
>> 
>> See
>> 
>>  
>> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html
>>  
>> http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo2.html
>> 
>> and
>> 
>>  http://matplotlib.sourceforge.net/search.html?q=codex+set_minor_locator
>> 
>> To control the tick properties themselves, see the Tick section in
>> 
>>  http://matplotlib.sourceforge.net/users/artists.html
>> 
>> JDH
>> 
>> 
> 
> As John mentioned, the major and minor ticks were the taller and shorter 
> ticks, respectively. In your pasted example, you only change the minor ticks; 
> by setting the majorLocator to same value as in the original example (i.e. 
> 20), you only get the major tick at 0 because your data only goes to 1.5 
> (i.e. 20 is outside your plot range).
> 
> Also, the majorFormatter in the example is set to work with integers, but 
> your major tick labels should be float values (since most of them are between 
> 0 and 1). Thus, the majorFormatter code is unnecessary (commented out below).
> 
> Finally, a pet peeve: when posting example code, please make the effort to 
> generate data for the plot so that others can easily run the code (see 
> attached).
> 
> -Tony
> 
> #---
> 
> import numpy as np
> import matplotlib.pyplot as plt
> from matplotlib.ticker import MultipleLocator, FormatStrFormatter
> 
> def gera_grafico(N=200, eps=1):
> 
> x = np.abs(np.random.randn(N))
> y = 10*np.log((30*x + 1.)**(0.5)) + 34 + eps * np.random.randn(N)
> yerr = eps * np.random.randn(N)
> 
> majorLocator   = MultipleLocator(0.2)
> # majorFormatter = FormatStrFormatter('%d')
> minorLocator   = MultipleLocator(0.02)
> 
> fig, ax = plt.subplots()
> plt.errorbar(x, y, yerr, fmt='ob', label='date')
> 
> plt.xlim(0.0, 1.5)
> #plt.xscale('log')
> #grid(True)
> 
> ax.xaxis.set_major_locator(majorLocator)
> # ax.xaxis.set_major_formatter(majorFormatter)
> 
> ax.xaxis.set_minor_locator(minorLocator)
> 
> return fig
> 
> if __name__ == '__main__':
> gera_grafico()
> plt.show()
> 
> 
> 

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Mac binary updated: bad file permission

2010-10-08 Thread Russell E. Owen
The Mac installer for matplotlib that I recently announced had a bug: a 
file in dateutil had bad permissions. I think I've finally got that 
straightened out and there's a new installer here:


My apologies for the error.

-- Russell


--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Xtick label size in ImageGrid

2010-10-08 Thread Justin McCann
I just refactored some custom code to make use of
axes_grid1.ImageGrid, and I think I've come across a bug (see below).
It looks like the tick labelsize doesn't get passed properly to the
parasite axes.

I'm using Python2.6, matplotlib-1.0.0 release, and the Qt4Agg backend.

Also, I noticed that the Grid.__init__ super-class constructor isn't
called in the ImageGrid.__init__ constructor; should it be?

By way of feature request, I'd prefer to be able to specify share_x
and share_y in the constructor, but that's not available in ImageGrid,
only in Grid.

If there's agreement that this is bug, I'll file it on the sourceforge
tracker. Is this fixed in SVN, or does anyone have workaround, e.g.,
some way to convert 'x-small' to the correct integer size, or a
different method to call?

Thanks,
Justin


from mpl_toolkits.axes_grid1 import ImageGrid
import pylab
import numpy
row_height = 10
fi = pylab.figure()
grid = ImageGrid(fi, 111, nrows_ncols=(5,1), share_all=False, label_mode='l')
for i in range(5):
a = abs(numpy.random.randn(5,100))
im = grid[i].imshow(a)

cb = grid.cbar_axes[0].colorbar(im)
for ax in grid.axes_all:
ax.set_yticks([])

# oops - this only changes the lowest Axes formatting
grid.axes_llc.tick_params(direction='out', labelsize='x-small')
pylab.show()
# Now pan to the left a bit-- you'll see the large 0 from the 100 xtick_label

# Let's try explicitly setting all of the xtick sizes. Kablooie.
for ax in grid.axes_all:
    ax.tick_params(direction='out', labelsize='x-small')


---
TypeError                                 Traceback (most recent call last)
/tmp/ in ()
.../matplotlib/axes.pyc in tick_params(self, axis, **kwargs)
   2215             xkw.pop('labelleft', None)
   2216             xkw.pop('labelright', None)
-> 2217             self.xaxis.set_tick_params(**xkw)
   2218         if axis in ['y', 'both']:
   2219             ykw = dict(kwargs)
.../matplotlib/axis.pyc in set_tick_params(self, which, reset, **kw)
    795             if which == 'major' or which == 'both':
    796                  for tick in self.majorTicks:
--> 797                     tick._apply_params(**self._major_tick_kw)
    798             if which == 'minor' or which == 'both':
    799                  for tick in self.minorTicks:
.../matplotlib/axis.pyc in _apply_params(self, **kw)
    274         if dirpad:
    275             self._base_pad = kw.pop('pad', self._base_pad)
--> 276             self.apply_tickdir(kw.pop('tickdir', self._tickdir))
    277             trans = self._get_text1_transform()[0]
    278             self.label1.set_transform(trans)
.../matplotlib/axis.pyc in apply_tickdir(self, tickdir)
    331         else:
    332             self._tickmarkers = (mlines.TICKDOWN, mlines.TICKUP)
--> 333             self._pad = self._base_pad + self._size
    334
    335
TypeError: unsupported operand type(s) for +: 'int' and 'str'

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Xtick label size in ImageGrid

2010-10-08 Thread Jae-Joon Lee
The label_mode need to be capital "L", instead of "l". I guess this
will fix your first problem.
While we make "l" same as "L", but I think it actually degrade the
readability of the code, and I;m inclined to leave it as is. Let me
know if you have any suggestions though.

On Sat, Oct 9, 2010 at 5:43 AM, Justin McCann  wrote:
> # Let's try explicitly setting all of the xtick sizes. Kablooie.
> for ax in grid.axes_all:
>     ax.tick_params(direction='out', labelsize='x-small')
>

The second one is not actually related with axes_grid1 toolkit. The
error can be reproduced with the code below.

ax = subplot(111)
ax.tick_params(direction='out', labelsize='x-small')
ax.tick_params(direction='out', labelsize='x-small')

The 1st tick_params is okay, but the 2nd one raises an error.
I'll take a look into it soon. Meanwhile, you may use a numeric
argument for the labelsize.

Regards,

-JJ

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Xtick label size in ImageGrid

2010-10-08 Thread Jae-Joon Lee
Eric,

ax = subplot(111)
ax.tick_params(labelsize='x-small')
print ax.xaxis.majorTicks[0]._size

it sets Tick._size instead of Tick._labelsize, which seems to be a bug.

I think the below patch fixes this. Can you check (and commit if correct)?

Regards,

-JJ


diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py
index 585c1a2..05e7bec 100644
--- a/lib/matplotlib/axis.py
+++ b/lib/matplotlib/axis.py
@@ -299,7 +299,7 @@ class Tick(artist.Artist):
 label_kw = dict([(k[5:], v) for (k, v) in label_list])
 self.label1.set(**label_kw)
 self.label2.set(**label_kw)
-for k, v in label_kw.items():
+for k, v in label_list:
 setattr(self, '_'+k, v)





On Sat, Oct 9, 2010 at 12:10 PM, Jae-Joon Lee  wrote:
> The label_mode need to be capital "L", instead of "l". I guess this
> will fix your first problem.
> While we make "l" same as "L", but I think it actually degrade the
> readability of the code, and I;m inclined to leave it as is. Let me
> know if you have any suggestions though.
>
> On Sat, Oct 9, 2010 at 5:43 AM, Justin McCann  wrote:
>> # Let's try explicitly setting all of the xtick sizes. Kablooie.
>> for ax in grid.axes_all:
>>     ax.tick_params(direction='out', labelsize='x-small')
>>
>
> The second one is not actually related with axes_grid1 toolkit. The
> error can be reproduced with the code below.
>
> ax = subplot(111)
> ax.tick_params(direction='out', labelsize='x-small')
> ax.tick_params(direction='out', labelsize='x-small')
>
> The 1st tick_params is okay, but the 2nd one raises an error.
> I'll take a look into it soon. Meanwhile, you may use a numeric
> argument for the labelsize.
>
> Regards,
>
> -JJ
>

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] ellipk

2010-10-08 Thread Pau
Hi,

didn't work...

ImportError: No module named scipy.special

this is fedora13...

thanks!

Pau

2010/10/8, Sebastian Busch :
> hey pau,
>
> ellipk is in scipy.special:
>
> #!/usr/bin/env python
> from pylab import *
> from scipy.special import ellipk
>
> e=1.
> a_mpc = 4.0
> p = a_mpc * (1 - e**2.)
> Phase = 4.*sqrt(p/(p -6. - 2.*e)) * ellipk(-4.*e/(p - 6. -2.*e))
>
>
> greetings,
> sebastian.
>
>


2010/10/8, Sebastian Busch :
> hey pau,
>
> ellipk is in scipy.special:
>
> #!/usr/bin/env python
> from pylab import *
> from scipy.special import ellipk
>
> e=1.
> a_mpc = 4.0
> p = a_mpc * (1 - e**2.)
> Phase = 4.*sqrt(p/(p -6. - 2.*e)) * ellipk(-4.*e/(p - 6. -2.*e))
>
>
> greetings,
> sebastian.
>
>

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users