Hi Mathieu,

It seems to me that you're confused with the meaning of the transAxes.
It is a transform from the Axes coordinate to the Canvas(?) coordinate.
As far as I can see, what you seemed to want is a transform between
Data coordinate and Axes coordinate, and that would be transScale +
transLimits (from Data to Axes).

So, try

   trans = (ax.transScale + ax.transLimits).inverted()
   # trans = ax.transLimits.inverted() will also work in this case.

and you will get 2.0, 2.0 as you expected.

The "transform" argument should be transAxes still.

   ax.text(valx, valy, actualcoords, transform=ax.transAxes)

As far as your original question is concerned, I have little idea what
you are trying to do, so I'll leave that question to others.

Regards,

-JJ


On Thu, Aug 14, 2008 at 3:43 PM, Mathieu Leplatre <[EMAIL PROTECTED]> wrote:
> I am still investigating and I am stuck at converting transAxes values to 
> data.
>
> If my axes goes from 10.0 to 20.0 then transAxes 0.5 should give me 15.0.
>
> This would allow me to compute bar width and space, since I am able to
> convert inches to transAxes values.
>
> I tried many combinations of transAxes, transData, ...,
> inverse_xy_tup, xy_tup, inverted(), transform(), ... without success
> :(
>
> Any ideas please ?
>
> -----
> import pylab as P
> import matplotlib.transforms as T
>
> x = P.arange(5)
> y = P.rand(5) * 4
> ax = P.subplot(1,1,1)
> P.plot(x,y)
> ax.set_ylim(0.0, 4.0)
>
> trans = ax.transAxes
> valx = valy = 0.5
> actualcoords = "%s" % trans.transform([valx, valy])
> #Gives me [328, 240] instead of [2.0, 2.0]
>
> ax.text(valx, valy, actualcoords, transform=trans)
> P.show()
>
> -----
>
>
>
> On Wed, Aug 13, 2008 at 10:34 AM, Mathieu Leplatre <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> I've searched in examples and archives and could not find anything
>> about manual control of space between bars.
>>
>> By default, the bars in the following script overlap.
>>
>> So I guess the behaviour is :
>> specify chart width (8in) + bar width (0.8) => auto bar space
>>
>> And I would like to know how to do :
>> specify chart width + bar space => auto bar width
>> specify bar space + bar width => auto chart width (fixed margins)
>>
>> But I can't figure it out, especially the latter. Can
>> matplotlib.transforms help me about the former ?
>>
>> Do you have documentation reference or some hints about that please ?
>> Thanks!
>>
>> I am plotting a chronological bar chart like this one :
>>
>> #!/usr/bin/env python
>> import matplotlib, pylab, numpy
>> import datetime
>>
>> def rangedates( hourstep ):
>>        dates = []
>>        for d in range(1,31):
>>                for h in range(0,24,hourstep):
>>                        dt = datetime.datetime(2008,06,d,h)
>>                        dates.append(dt)
>>        return pylab.date2num(dates)
>>
>> # Plot value every 12H
>> abscissa = rangedates(12)
>>
>> barstep  = abscissa[1] - abscissa[0]
>> barspace = 0.5 * barstep
>> barwidth = barstep - barspace
>>
>> fig = pylab.figure()
>> ax  = fig.add_subplot(111)
>> fmt = matplotlib.dates.DateFormatter('%b %d')
>> ax.xaxis.set_major_formatter( fmt )
>> fig.autofmt_xdate()
>>
>> pylab.bar( abscissa, numpy.random.randn( len(abscissa) ),
>>           width = barwidth)
>> pylab.show()
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to