[yt-users] Plot titles

Matthew Turk matthewturk at gmail.com
Tue Jun 16 12:10:39 PDT 2009


Hi Dave,

I have added this to the trunk repository and yt-1.5.  Incidentally,
the invocation of callbacks has become much simpler (and I am in the
midst of documenting this, but this particular section is already
online: http://yt.enzotools.org/doc/howto/quick_plots.html#plot-modification
) and you can invoke them by using the "modify" attribute:

profile = pc.add_profile_object(...)
profile.modify["title"]("MyPlot")

is the shorter and more straightforward way.  I would encourage you
not to use the manual add_callback method, as it's clunky and ugly and
I regret setting it up that way in the first place.

-Matt

On Tue, Jun 16, 2009 at 11:44 AM, David
Collins<dcollins at physics.ucsd.edu> wrote:
>> I believe that you should be okay directly modifying the _axes object
>> of the plot, if you are modifying profile plots.  This is probably not
>
>> plot = pc.add_phase_sphere(...)
>> plot._axes.title("My Title")
>
> This was the first thing that I tried, but it looks like the title
> field gets wiped during the save. I did
>
>>>> pf = MyOutputs.FileStaticOutput(file)
>>>> pc = raven.PlotCollection(pf)
>>>> region = pf.h.region([0.5]*3,[0.0]*3,[1.0]*3)
>>>> profile = pc.add_profile_object(region,['Density','VolumeFraction'])
>>>> profile._axes.set_title('Bacon Hat Density')
>>>> print profile._axes.title
> Text(1,1,'Bacon Hat Density')
>>>> pc.save('stuff.png')
>>>> print profile._axes.title
> Text(1,1,'')
>
> and there's no title on the resulting plot.  Is there something
> obviously dumb with the above, aside from the plot title?
>
> I can make a callback that does it, and it works fine, though-- for
> those of you following along, I did
>
> class title(raven.PlotCallback):
>    def __init__(self, title="Plot"):
>        self.title = title
>    def __call__(self,plot):
>        plot._axes.set_title(self.title)
>
> profile.add_callback(dave_callback.title(title))
>
>
> d.
>
>>
>> You could accomplish this by something like:
>>
>> plot = pc.add_phase_sphere(...)
>> plot._axes.title("My Title")
>>
>> You can also access the figure with _figure.
>>
>> The callback interface is something of a pragmatic approach to the
>> system of plotting used for variable mesh plots -- slices,
>> projections, etc.  The idea was that one should be able to overlay a
>> set of data-oriented modifications to the plot, because for a given
>> plot, multiple images might get saved, for instance at different
>> widths.  So I set up a system of "callbacks" designed such that every
>> time the plot was erased and recreated, it would have (laid on top)
>> the same contours, or velocity, but changed the same way the image had
>> been changed.  So for a "Density" zoomin, you'd only have to add the
>> "Temperature" contours once, and every time you changed the width they
>> would be updated.
>>
>> Because the variable mesh plots have their axes wiped between updates
>> of the image data, all the other data plotted on those axes are wiped
>> as well.  That's why the callbacks are necessary for things like
>> simple annotations.  The long term strategy for the callbacks is to
>> provide a much simpler interface for very simple things.  I hope to
>> implement this very soon.
>>
>> -Matt
>>
>> On Mon, Jun 15, 2009 at 4:41 PM, david collins<antpuncher at gmail.com> wrote:
>>> Hi--
>>>
>>> Is there a non-callback way to add plot titles to things like profiles?
>>>
>>> d.
>>> _______________________________________________
>>> 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
>



More information about the yt-users mailing list