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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
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.Font... 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#acc... 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@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
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@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.Font...
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#acc...
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@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
Hi Junhwan, I can provide you a quick hack to do this, while it is ugly and be careful to save your backup file. In the file: src/yt-hg/yt/visualization/plot_window.py You could search for the following lines: class PlotWindow(object): _plot_valid = False _colorbar_valid = False _contour_info = None _vector_info = None _frb = None def __init__(self, data_source, bounds, buff_size=(800,800), antialias=True, periodic=True, origin='center-window', oblique=False, fontsize=15): In the last line, change the font size to a larger number. After that you'll find both the ticks and labels of axis and colorbar become larger. However, if you use log plot, you'll find the exponent number at the top of the axis remains small. Then you could add these in your own script: import matplotlib matplotlib.rcParams.update({'font.size': YOURSIZE}) My yt version might be a little out-of-date, so please also be cautious when you do the modification. Hope it works for you, although it's not an elegant way... Best wishes, Suoqing On Mar 25, 2013, at 11:38 PM, Jun-Hwan Choi <jhchoi@pa.uky.edu> 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@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.Font...
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#acc...
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@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
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... 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@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.Font...
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#acc...
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@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@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
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...
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@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.Font...
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#acc...
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@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
_______________________________________________ yt-users mailing list yt-users@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@pa.uky.edu URL: http://www.pa.uky.edu/~jhchoi --------------------------------------------------------------
participants (5)
-
Ji Suoqing
-
John Wise
-
Jun-Hwan Choi
-
Jun-Hwan Choi
-
Nathan Goldbaum