[yt-users] Adjusting fontsize on yt SlicePlot
Nathan Goldbaum
nathan12343 at gmail.com
Sat Sep 19 20:16:23 PDT 2015
On Sat, Sep 19, 2015 at 4:38 PM, DORIS LEE <dorislee at berkeley.edu> wrote:
> Hi all,
> I am trying to adjust the fontsize of the title and text of a yt
> SlicePlot. It looks like TitleCallback could be used to make the plot
> setting same as the font attributes set in the SlicePlot, but it errors
> because SlicePlot doesn't have an axes.Is there a simpler way to feed in a
> plot_args diction in the parameter for these plot annotate_title and
> annotate_text functions?
> Thank you.
>
>
> ds= yt.load("output_00001/info_00001.txt")
>>>
>>> slc = yt.SlicePlot(ds, "z","density" ,window_size=7)
>>>
>>> slc.set_font_size(20)
>>>
>>> title=yt.visualization.plot_modifications.TitleCallback("title")
>>>
>>> title(slc)
>>>
>>>
Hi Doris,
This isn't the proper way to call the title callback. There's some magic in
the PlotWindow class to associate the TitleCallback class with the
annotate_title function. The line you've commented out below is the proper
way to do it. The TitleCallback class itself is a part of yt's internals
and should not be used directly in your scripts.
As Cameron pointed out, as of yt 3.2 the text callback accepts a
`coord_system` keyword argument. The fact that it failed for you indicates
that you're likely on yt-3.1 before that functionality was added. I'd urge
you to update to the latest stable version of yt (version 3.2.1) which
includes a large number of fixes for bugs in the version you're using.
There are instructions on how to update your yt installation here:
http://yt-project.org/doc/installing.html
If you installed using the install script or from a clone of the yt
mercurial repository, it should be as easy as doing "yt update". If you
installed using pip, you should be able to do "pip install -U yt" (might
need additional command line arguments depending on your python
installation, described in the link above), and if you installed using
conda you should be able to do "conda update yt".
I've uploaded a notebook here that I evaluated using yt 3.2.1 and one of
the public test datasets on yt-project.org/data:
https://gist.github.com/e3fb912480c0ac25fcf8
It demonstrates the functionality that Cameron and I are discussing.
Hope that helps,
Nathan
> # slc.annotate_title("Test")
>>>
>>> slc.annotate_text((0,1),"timestep #:")
>>>
>>>
> ---------------------------------------------------------------------------AttributeError Traceback (most recent call last)<ipython-input-63-fc5ce857c791> in <module>() 3 slc.set_font_size(20) 4 title=yt.visualization.plot_modifications.TitleCallback("title")----> 5 title(slc) 6 # slc.annotate_title("Test") 7 slc.annotate_text((0,1),"timestep #:")
> /global/homes/d/dorislee/mypythonpackages/yt/visualization/plot_modifications.pyc in __call__(self, plot) 1087 1088 def __call__(self,plot):-> 1089 plot._axes.set_title(self.title) 1090 1091 class TimestampCallback(PlotCallback):
> AttributeError: 'AxisAlignedSlicePlot' object has no attribute '_axes'
>
>
>
> Doris
>
> _______________________________________________
> 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/20150919/9a165fa8/attachment.html>
More information about the yt-users
mailing list