[yt-users] Fonts size in the Projection plot.

Nathan Goldbaum nathan12343 at gmail.com
Mon Mar 25 19:46:00 PDT 2013


Hi Junhwan,

You can set the font properties using the set_font function:

>>> slc = SlicePlot(pf, 'x', 'Density')
>>> font_dict = {'family':'sans-serif', 'style':'italic',
                        'weight':'bold', 'size':24}
>>> slc.set_font(font_dict)

Here, font_dict is a dictionary of keywords that will be passed to the
matplotlib FontProperties object for the plot.  For more details about
FontProperties, take a look at the matplotlib documentation:
http://matplotlib.org/api/font_manager_api.html#matplotlib.font_manager.FontProperties

One caveat is that the axes labels use MathText which is tied to a special
computer modern font that is bundled with matplotlib.  For that reason, you
will only be able to adjust the size of the axes labels, not the font.

Another caveat is that you cannot set the tick label color using set_font.
 Instead, you'll need to iterate over the actual tick label objects as in
this example from the docs:
http://yt-project.org/doc/cookbook/simple_plots.html?highlight=dinosaurs#accessing-and-modifying-plots-directly

Finally, you'll need to set the font properties for the text
annotation separately:

>>> slc.annotate_text((-45,42.5), "a)", data_coords=False, text_args =
font_dict)

The text_args keyword of annoate_text does accept color as a keyword, so
you'll be able to pass it in with font_dict.

The full list of allowed keywords for text_args is on this page from the
matplotlib docs: http://matplotlib.org/users/text_props.html

Hope that's helpful.  Sorry that's not as simple as it could be, this is
one area of the plotting routines where it would be nice to simplify things.

-Nathan

On Mon, Mar 25, 2013 at 6:13 PM, Jun-Hwan Choi <jhchoi at pa.uky.edu> wrote:

> Hi yt user,
>
> I make a very simple projection plot using following script:
>
> ==========
> from yt.mods import *
>
> # Load the dataset.
> pf = load("../RunDM1/DD0134/DD0134")
> center = na.array([0.5,0.5,0.5,])
>
> # Making slice
> slc = ProjectionPlot(pf, 2,'Density', center,(100, 'pc') , 'Density')
> slc.annotate_text((-45,42.5), "a)", data_coords=False)
> slc.save("Run1")
> ==========
>
> It generate plot with x, y, z labels and ticks as well text "a)"
> I would like to increase the font size of label, ticks, and text.
> I also change the color of the text.
> I think it is very basic operation, but I can not find the way.
> Can anyone help me?
>
> Thanks in advance,
> Junhwan
>
>
> --
> --------------------------------------------------------------
> Jun-Hwan Choi, Ph.D.
> Department of Physics and Astronomy, University of Kentucky
> Tel: (859) 897-6737        Fax: (859) 323-2846
> Email: jhchoi at pa.uky.edu   URL: http://www.pa.uky.edu/~jhchoi
> --------------------------------------------------------------
>
>
> _______________________________________________
> 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/20130325/3dbfeb42/attachment.html>


More information about the yt-users mailing list