Re: [Matplotlib-users] Annotate value of a variable with ax.annotate?

2011-05-01 Thread Malte Dik
Hi,

Pau 
> Hello,
> 
> I am trying to print in the plot the value of a time variable which I
> obtain like this
> 
> Time   = MBH_inst[0]  # Column 1
> 
> This should be placed on the top right part of the plot showing the current
> time
> 
> Time = XXX yrs
> 
> But I do not know how to pass this to ax.annotate:
> 
> ax.annotate('Time = ', size=18, xy=(3, 1),  xycoords='data',
> xytext=(0.8, 0.95), textcoords='axes fraction',
> horizontalalignment='right', verticalalignment='top',
> )

Maybe like this:

ax.annotate('Time = %f'%(MBH_inst[0],), size=18, xy=(3, 1),  xycoords='data',
xytext=(0.8, 0.95), textcoords='axes fraction',
horizontalalignment='right', verticalalignment='top',
)
?

You can also adjust the number of shown digits right of the comma by setting 
it up like this: %0.2f etc.

Just look it up in the python documentation (search hints: python string 
format).


Wish you the best,

Malte

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] tk development packages

2010-07-24 Thread Malte Dik
Hi,

>  Can anyone please tell me about the tk development packages. Where  can I
> find the tk development packages .

This heavily depends on which operating system and distribution you are using.

Always give as much info as you can about your system so others can help you.


Have a nice day,

Malte

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Display the 'full' value on y axis

2010-07-19 Thread Malte Dik
Hi,

as you can see here (lotlib.sourceforge.net/api/ticker_api.html),
you need to set your formatter to either ScalarFormatter and set it up, so no 
offset is used or FormatStrFormatter with something like %d.


Kind regards,

Malte Dik

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Unequal size gangplots

2010-06-21 Thread Malte Dik
Jeremy Conlin 
> I have followed this excellent example:
> http://matplotlib.sourceforge.net/examples/pylab_examples/ganged_plots.html
> 
> but I would like my plots to be 2/3 and 1/3 of the total height of the
> figure (I only have 2 plots).  What do I have to do to specify the
> relative sizes of the figures?

may something like

ax1 = fig.add_subplot(311)
ax2 = fig.add_subplot(212)

work?

if I look at pyplot.setp(ax1) I see a lot of things (like "position" or 
"anchor" or "axes_locator") which might work.

Good luck,

Malte

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlab freezes with a graph and toolbar

2010-06-16 Thread Malte Dik
Hi,

is it helpful to write that both of you examples doesn't crash anything for me 
(except the second only being able to be "$kill"ed)?

m...@eee:~$ uname -a
Linux eee 2.6.29-2-686 #1 SMP Sun May 17 17:56:29 UTC 2009 i686 GNU/Linux
m...@eee:~$ python --version
Python 2.5.5


Regards,

Malte

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Placing images on figures

2010-06-16 Thread Malte Dik
Hi,

Eamon Caddigan 
> The reason my initial attempts failed was because I (erroneously)
> assumed that the default axis spanned (0, 0), (1, 1). Now I that I
> know better, I can place an axis for each image in the right place and
> everything looks fine.
> 
> However, I'm still interested in knowing how to query the pixel size
> of the figure, so I can translate normalized axis coordinates to pixel
> coordinates.

http://matplotlib.sourceforge.net/users/transforms_tutorial.html

Maybe something along the lines
ax.transAxes.transform((0, 0)) - ax.transAxes.transform((1, 1))
?

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] multiple lines

2010-06-01 Thread Malte Dik
Howard Sun 
> Sorry for the newbie question, how do you plot one x with multiple ys. In
> below data, x column is followed by 5 y columns: Many thanks!
> Howard
> 
> 2 1.e+00 6.6232e-02 9.9392e-03 2.2992e-02 3.8111e-07
> 3 6.3664e-01 1.0269e-01 7.9107e-03 1.8254e-02 1.1391e-07
> 4 2.7590e-01 4.9783e-02 6.2644e-03 1.0943e-02 5.8480e-08
> 5 1.6550e-01 2.3269e-02 4.7482e-03 8.4312e-03 5.8239e-08
> 6 1.1590e-01 1.7234e-02 3.8567e-03 8.7010e-03 4.5506e-08
> 7 7.4337e-02 1.1662e-02 3.3756e-03 8.0889e-03 4.0900e-08
> 8 5.7775e-02 1.0917e-02 2.8980e-03 6.9654e-03 3.7520e-08
> 9 4.7310e-02 1.1869e-02 2.5929e-03 5.8326e-03 3.4745e-08
> 10 3.9591e-02 1.1301e-02 2.4691e-03 5.2749e-03 3.2126e-08
> 11 3.6517e-02 1.0755e-02 2.3121e-03 4.8631e-03 3.7942e-08
> 12 3.2872e-02 9.8306e-03 2.1692e-03 4.6281e-03 3.2358e-08
> 13 3.1235e-02 9.1704e-03 2.0419e-03 4.3928e-03 3.1479e-08
> 14 2.9528e-02 8.6926e-03 1.9364e-03 4.1360e-03 3.5639e-08
> 15 2.7895e-02 8.3080e-03 1.8475e-03 3.9015e-03 3.0486e-08
> 16 2.6440e-02 7.9610e-03 1.7776e-03 3.6790e-03 3.0307e-08
> 17 2.5259e-02 7.6345e-03 1.6984e-03 3.4743e-03 3.1805e-08
> 18 2.4064e-02 7.3267e-03 1.6341e-03 3.2848e-03 3.0188e-08
> 19 2.3171e-02 7.0284e-03 1.5821e-03 3.1098e-03 2.7565e-08
> 20 2.2317e-02 6.7322e-03 1.5247e-03 2.9475e-03 2.7009e-08


First, you take the data apart, like in:

import csv, numpy

# let's call your array "filecopy"

d = csv.Sniffer().sniff(filecopy[0])

for this_one_line in csv.reader(filecopy, d):
header = this_one_line
break

data = numpy.zeros((len(header), len(filecopy)))

for line in csv.reader(filecopy[1:], d):
for n in range(len(header)):
data[n][linecounter] = float(line[n])
linecounter += 1

And then, you plot it:

from matplotlib import pyplot

fig = pyplot.figure()
s = fig.add_subplot(1, 1, 1)
for c in data:
s.plot(data[0], c)

pyplot.show()



Obviously, that's all taken from another script and won't work "as is" and 
there might be functions which would make some of this easier.

The main reason for posting this is being that bad that someone couldn't take 
the pain and post something better - and me learning in the process.



Sincerely,

Malte













--

___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Formatting X-axis

2010-05-17 Thread Malte Dik
Hi,

> Is there any API to draw the lines between the labels?
> I guess its not possible with this tool.

You could use the ticks' properties (one of their children is a 
matplotlib.lines.Line2D instance which you could modify to your wishes). The 
second possibility is see is you put a box with only two drawn borders around 
the labels, which I think might lead to problems.

So if you want to inspect, what you can do with those ticks you can use

pyplot.getp(object_to_inspect) and pyplot.setp(object_to_inspect) aswell as
dir(object_to_inspect).

I mostly do this by having an open python shell where I create and check out 
the properties I want to work on and a little script I modify to check out how 
the changes affect the plot. What I did looked something like this:

>>> from matplotlib import pyplot
>>> fig = pyplot.figure()
>>> p = fig.add_subplot(111)
>>> p.yaxis.set_ticks([3,4,5]) 
[, , ]
>>> m = p.yaxis.set_ticks([3,4,5])
>>> dir(m[0])
['__class__', '__d..., 'get_children', 'get_cli...]
>>> pyplot.getp(m[0])
alpha = 1.0
...
children = [, >> m[0].get_children()
>>> pyplot.getp(m[0].get_children()[0])
>>> pyplot.setp(m[0].get_children()[0])

and if you don't have the return of creating the ticks ("m" in this case) then 
you can get then using
>>> p.yaxis.get_children()
[, , , 
, , , 
]

Hope it helps,

Malte

--

___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users