<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div dir="ltr">Hi Mike,<div><br></div><div>It will use MathText if you ask for a logarithmically scaled colorbar.</div><div><br></div><div>There's probably a way to do it by spelunking a bit inside the matplotlib API, but I don't know of an easy way to do it off-hand.</div>

<div><br></div><div>If all you care about is the font, you can also use the 'stixgeneral' font family, which is actually the font that matplotlib uses internally to display mathtext.  You can change the font globally by updating your matplotlibrc or changing your matplotlib configuration at the top of your script.</div>

<div><br></div><div>Sorry I can't be more helpful.  Let us know if you come up with a solution here.</div><div><br></div><div>-Nathan</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 8:38 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">here's my script (also here: <a href="http://bender.astro.sunysb.edu/random/slice3plot.py" target="_blank">http://bender.astro.sunysb.edu/random/slice3plot.py</a> )<div>

<br></div><div><div>#!/bin/env python</div><div><br>
</div><div>import argparse</div><div><br></div><div>import yt</div><div><br></div><div>import matplotlib</div><div>import matplotlib.pyplot as plt</div><div>from mpl_toolkits.axes_grid1 import AxesGrid</div><div><br></div>


<div>def doit(file, var, log):</div><div><br></div><div>    # load the data</div><div>    ds = yt.load(file)</div><div>    dd = ds.all_data()</div><div><br></div><div>    center = 0.5*(ds.domain_left_edge + ds.domain_right_edge)</div>


<div><br></div><div>    # see <a href="http://yt-project.org/docs/3.0/cookbook/complex_plots.html#multipanel-with-axes-labels" target="_blank">http://yt-project.org/docs/3.0/cookbook/complex_plots.html#multipanel-with-axes-labels</a></div>


<div><br></div><div>    fig = plt.figure()</div><div><br></div><div>    grid = AxesGrid(fig, (0.1, 0.1, 0.85, 0.85),</div><div>                    nrows_ncols = (1, 3),</div><div>                    axes_pad = 1.1,</div>

<div>
                    label_mode = "all",</div><div>                    share_all = False,</div><div>                    cbar_location = "right",</div><div>                    cbar_mode = "each",</div>


<div>                    cbar_size = "3%",</div><div>                    cbar_pad = "0%")</div><div><br></div><div>    formatter = matplotlib.ticker.ScalarFormatter(useMathText=True)</div><div>    formatter.set_powerlimits((-3,3))</div>


<div><br></div><div>    for i, d in enumerate(["x", "y", "z"]):</div><div class=""><div><br></div><div>        p = yt.SlicePlot(ds, d, var, center=(center[0], center[1], center[2]),</div><div>

                         origin="native", fontsize=10)</div>
<div>        p.set_log(var, log)</div><div><br></div><div>        plot = p.plots[var]</div><div>        plot.figure = fig</div><div>        plot.axes = grid[i].axes</div><div>        plot.cax = grid.cbar_axes[i]</div><div>


        </div></div><div>        #cb.formatter.set_scientific(True)</div><div>        #cb.formatter.set_powerlimits((-3,3))</div><div>        #plot.cax.yaxis.set_major_formatter(formatter)</div><div><br></div><div>        cb = plot.cb</div>


<div>        cb.formatter = formatter</div><div>        cb.update_ticks()</div><div><br></div><div><br></div><div>        p._setup_plots()</div><div><br></div><div>        ax = plot.axes</div><div>        ax.xaxis.set_major_formatter(formatter)</div>


<div>        ax.yaxis.set_major_formatter(formatter)</div><div><br></div><div>        ax.xaxis.offsetText.set_fontsize("small")</div><div>        ax.yaxis.offsetText.set_fontsize("small")</div><div>        <br>


</div><div><br></div><div>    fig.set_size_inches(12.80, 7.20)</div><div><br></div><div>    plt.savefig("test.png")</div><div><br></div><div>    </div><div><br></div><div><br></div><div>if __name__ == "__main__":</div>


<div><br></div><div>    parser = argparse.ArgumentParser()</div><div><br></div><div>    parser.add_argument("--log", help="plot the log of the variable", action="store_true")</div><div>    </div>


<div>    parser.add_argument("file", help="the name of the file to read", type=str)</div><div>    parser.add_argument("var", help="the name of the variable to plot", type=str)</div>


<div><br></div><div>    args = parser.parse_args()</div><div><br></div><div>    doit(args.file, args.var, args.log)</div><div><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">

On Wed, Aug 20, 2014 at 11:34 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">yeah, I was doing that -- it doesn't have an effect.</div><div><div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 11:33 AM, Chris Malone <span dir="ltr"><<a href="mailto:chris.m.malone@gmail.com" target="_blank">chris.m.malone@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hey Mike,<br><br></div>I'm not sure if this is the issue or not, but after you apply your formatter to the colorbar, you need to call cbar.update_ticks() for them to actually change.<br>



<br>Chris<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Wed, Aug 20, 2014 at 9:12 AM, Michael Zingale <span dir="ltr"><<a href="mailto:michael.zingale@stonybrook.edu" target="_blank">michael.zingale@stonybrook.edu</a>></span> wrote:<br>




</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Does anyone know how to make a SlicePlot colorbar from yt use mathtext in the tick labels?  I am doing the following in a loop over x, y, z planes:<div>




<br></div><div><br><div><div><div>        p = yt.SlicePlot(ds, d, var, center=(center[0], center[1], center[2]),</div>
<div>                         origin="native", fontsize=10)</div><div>        p.set_log(var, log)</div><div><br></div><div>        plot = p.plots[var]</div><div>        plot.figure = fig</div><div>        plot.axes = grid[i].axes</div>





<div>        plot.cax = grid.cbar_axes[i]</div></div><div><br></div><div>I can get at the colorbar object via cb = plot.cb, but I can't seem to turn on mathtext.  I can modify the axes to use my formatter so they look pretty, but I've tried to set a colorbar formatter with no success.</div>





<div><br></div><div>Here's my image:</div><div><br></div><div><a href="http://bender.astro.sunysb.edu/random/test.png" target="_blank">http://bender.astro.sunysb.edu/random/test.png</a><br></div><div><br></div><div>Notice that the offset text for the colorbar is "1.e6" instead of in latex (I still have to remove the offset text for the two rightmost y-axes later, but I know how to do that).</div>





<div><br></div><div>Mike</div><span><font color="#888888"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>




<div>
<i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>




<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</font></span></div></div></div>
<br></div></div>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>



<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>


<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div>


<div><i>phone</i>:  <a href="tel:631-632-8225" value="+16316328225" target="_blank">631-632-8225</a></div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div>

<div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div>

</div>
</div></div><br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>