[yt-users] title of PlotCollection

Sam Skillman samskillman at gmail.com
Tue Jul 17 08:12:00 PDT 2012


Hi Penfei,

It seems there might be a bug in the title callback.  In the meantime while
we fix the bug (I will file an issue to be resolved), you may want to use
the text callback:

If you want some text over on the right side near the colorbar, you should
have decent luck with:

p.modify['text']((1.15,0.9), 'z=%.2f'%z)

or if you want to place it in the middle, which you'd probably want the
color to be white, you could do something like:

p.modify['text']((0.5,0.9), 'z=%.2f'%0.1, text_args={'color':'w'})

The numbers in the () denote the fractional position in x,y in the image
part of the plot.  In both of those examples, I'm assuming you've defined z
somewhere, otherwise is will still fail.

Best,
Sam

On Tue, Jul 17, 2012 at 1:56 AM, Pengfei Chen <madcpf at gmail.com> wrote:

> Hi Nathan,
>
> Thank you very much for your reply! There is no error message after
> this modification, but there is still no title on the pdf/png I get.
> It's strange.
>
> Pengfei
>
> 2012/7/16 Nathan Goldbaum <nathan12343 at gmail.com>:
> > Hi Pengfei,
> >
> > I think you want to replace this line:
> >
> >
> > p.modify["title"](halos, text='z=%.2f'%z)
> >
> >
> > With the following:
> >
> > p.modify["title"]('z=%.2f'%z)
> >
> >
> > Cheers,
> >
> > Nathan
> >
> >
> > On 7/16/12 5:34 PM, Pengfei Chen wrote:
> >>
> >> Hi,
> >>
> >> I'm trying to add a title for the picture, but I can't find the right
> >> command to do so. Here is the code:
> >>
> >> pf = load(fn)
> >> halos = HaloFinder(pf)
> >> pc = PlotCollection(pf, [pos_x, pos_y, pos_z])
> >> p = pc.add_slice("Density", 0)
> >> pc.set_width(3*rad, '1')
> >> p.modify["hop_particles"](halos, max_number=100, alpha=0.3)
> >> p.modify["title"](halos, text='z=%.2f'%z)
> >>
> >> And there is some error reported for the last line. The meaning of the
> >> error is more than one name is given to the title. Then I replace it
> >> with:
> >>
> >> p.modify["text"](halos, pos=(0.02, 0.98), text='z=%.2f'%z)
> >>
> >> But it still has error. Could someone please help me about it?
> >>
> >> Pengfei
> >> _______________________________________________
> >> yt-users mailing list
> >> yt-users at lists.spacepope.org
> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >
> >
> >
> > _______________________________________________
> > yt-users mailing list
> > yt-users at lists.spacepope.org
> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20120717/7db934f7/attachment.html>


More information about the yt-users mailing list