[yt-users] text onto 3D image

Stephanie Tonnesen stonnes at gmail.com
Fri Jul 18 10:35:40 PDT 2014


Hi Michael,

Thanks for the quick reply!  I have been trying to make this work, and
can't seem to get text to show up.

My code looks like this:

>...
>import matplotlib.pylab as pl
>...

>from yt.visualization.volume_rendering.api import ColorTransferFunction

>tf = ColorTransferFunction((-29,-24))
>tf.add_layers(8,w=0.05,colormap="Hue Sat Value 2")
>tf.sample_colormap(-26.5,w=0.02,colormap="Hue Sat Value 2")
>cam = pf.h.camera([0.0,0.0,1.8],[0.0,-1.0,-0.2],4.4,1024,tf)

>im = cam.snapshot('rpsdip_'+sys.argv[1]+'_volumeall_vertcbar.png')
>tf.vert_cbar()
>cam.show_tf()
>nim=cam.draw_domain(im)
>f=pl.figure()
>timef = (58-6)*5
>pl.text(0.2,0.2,np.str(timef),transform=f.transFigure, color="white")
>pl.text(0.2,0.82,"Tonnesen",transform=f.transFigure, color='y')
>cam._render_figure=f
>cam.save_annotated('rpsdip_'+sys.argv[1]+'_volumeall_vertcbar_ann.png',nim,dpi=300)

I am getting a colorbar and the domain lines, but not the text.  I am
running yt2.7-dev.  Any idea on what I am doing wrong?

Thanks,

Stephanie


On Fri, Jul 18, 2014 at 10:46 AM, Michael Zingale <
michael.zingale at stonybrook.edu> wrote:

> Hi Stephanie, I added an optional argument to save_annotated that allows
> me to use an existing figure to render to.  I do something like this:
>
>     cam = vr.Camera(c, L, W, N, transfer_function=tf, pf=pf,
>                     no_ghost=False, #data_source=reg,
>                     fields = [field], log_fields = [use_log])
>
>    im = cam.snapshot()
>
>     cam.draw_coordinate_vectors(im)
>     cam.show_tf()
>     nim = cam.draw_domain(im)
>
>     f = pylab.figure()
>
>     pylab.text(0.2, 0.85, "{:.3g} s".format(float(pf.current_time.d)),
>                transform=f.transFigure, color="white")
>
>     cam._render_figure = f
>
>     cam.save_annotated("xrb_vol_{}.png".format(fname), nim, dpi=145,
> clear_fig=False)
>
>
> I plan to add an example to the docs about this once I am done travelling.
>
>
>
>
>
> On Fri, Jul 18, 2014 at 10:41 AM, Stephanie Tonnesen <stonnes at gmail.com>
> wrote:
>
>> Hi yt-ers,
>>
>> I am making individual snapshots of a simulation, using:
>>
>> >from yt.visualization.volume_rendering.api import ColorTransferFunction
>>
>> >tf = ColorTransferFunction((-29,-24))
>> >tf.add_layers(8,w=0.05,colormap="Hue Sat Value 2")
>> >tf.sample_colormap(-26.5,w=0.02,colormap="Hue Sat Value 2")
>> >cam = pf.h.camera([0.0,0.0,1.8],[0.0,-1.0,-0.2],4.4,1024,tf)
>> >im = cam.snapshot('rpsdip_'+sys.argv[1]+'_volumeall.png')
>>
>> I would like to add a timestamp to the frame (and possibly my name while
>> I'm at it!).  I know how to add text to a plot, but am not sure how to do
>> it here.  Any help is most appreciated!
>>
>> Thanks,
>>
>> Stephanie
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
>
> --
> Michael Zingale
> Associate Professor
>
> Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY
> 11794-3800
> *phone*:  631-632-8225
> *e-mail*: Michael.Zingale at stonybrook.edu
> *web*: http://www.astro.sunysb.edu/mzingale
>
> _______________________________________________
> 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/20140718/edd8a168/attachment.htm>


More information about the yt-users mailing list