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

Jun-Hwan Choi choi.junhwan at gmail.com
Tue Mar 26 07:51:44 PDT 2013


Thank you every one.

Junhwan

On 03/26/13 01:23, John Wise wrote:
> Hi Junhwan,
>
> The set_font routine was added about a month ago.
>
> https://bitbucket.org/yt_analysis/yt/pull-request/444/making-tick-labels-use-a-serif-font-by/diff
>
> If you could update your yt installation, this would probably fix this error.
>
> Thanks,
> John
>
> On 25 Mar 2013, at 23:38, Jun-Hwan Choi wrote:
>
>> Dear Nathan,
>>
>> Thank you for you help.
>> However, when I try to follow your suggestion, yt complains that
>>>> slc.set_font(font_dict)
>>>> AttributeError: 'ProjectionPlot' object has no attribute 'set_font'
>> Meanwhile, I try your approach only for annotate_text then it works.
>> So, now I can control the text size but I still can not find how increase x y label and tick size.
>> Is there other way to do so?
>>
>> Thank you,
>> Junhwan
>>
>>
>> On Mon, Mar 25, 2013 at 10:46 PM, Nathan Goldbaum <nathan12343 at gmail.com> wrote:
>> 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
>>
>>
>>
>>
>>
>> -- 
>> --------------------------------------------------------------
>> 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
> --
> John Wise
> Assistant Professor of Physics
> Center for Relativistic Astrophysics, Georgia Tech
>


-- 
--------------------------------------------------------------
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
--------------------------------------------------------------




More information about the yt-users mailing list