SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: per f. <per...@gm...> - 2010年01月31日 22:21:41
hi all,
two quick questions about labels. first, is there a way to make
subscripts/superscripts *without* using TeX in labels? For example, I
use helvetica in all my labels and I want to plot something like:
plt.xlabel("log10") where "10" is a subscript of "log", but without
doing: plt.xlabel(r"$\log_{10}$"), since that will use LaTeX fonts
instead of my helvetica font.
second question, when using TeX, I tried the following TeX command in labels:
plt.annotate(r"\frac{\sigma}{\sqrt{\mu}}", ....) but it complains that
"not all arguments converted during string formatting" -- but it seems
like correct TeX to me. if I try r"\frac{1}{2}" then it works, but
using \sigma and \sqrt inside breaks it.. any idea how to fix this?
thanks.
From: Gökhan S. <gok...@gm...> - 2010年01月31日 22:31:49
On Sun, Jan 31, 2010 at 4:21 PM, per freem <per...@gm...> wrote:
> hi all,
>
> two quick questions about labels. first, is there a way to make
> subscripts/superscripts *without* using TeX in labels? For example, I
> use helvetica in all my labels and I want to plot something like:
> plt.xlabel("log10") where "10" is a subscript of "log", but without
> doing: plt.xlabel(r"$\log_{10}$"), since that will use LaTeX fonts
> instead of my helvetica font.
>
Unicode strings might be the answer for this. Though needs someone's
confirmation.
>
> second question, when using TeX, I tried the following TeX command in
> labels:
> plt.annotate(r"\frac{\sigma}{\sqrt{\mu}}", ....) but it complains that
> "not all arguments converted during string formatting" -- but it seems
> like correct TeX to me. if I try r"\frac{1}{2}" then it works, but
> using \sigma and \sqrt inside breaks it.. any idea how to fix this?
>
Have you forgotten "$" ? The following works correctly in my system.
plt.xlabel(r"$\frac{\sigma}{\sqrt{\mu}}$")
>
> thanks.
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Gökhan
From: Eric F. <ef...@ha...> - 2010年01月31日 23:22:36
per freem wrote:
> hi all,
> 
> two quick questions about labels. first, is there a way to make
> subscripts/superscripts *without* using TeX in labels? For example, I
> use helvetica in all my labels and I want to plot something like:
> plt.xlabel("log10") where "10" is a subscript of "log", but without
> doing: plt.xlabel(r"$\log_{10}$"), since that will use LaTeX fonts
> instead of my helvetica font.
See the mathtext options in matplotlibrc.template. It looks like what 
you need is
matplotlib.rc('mathtext', fontset='stixsans')
maybe with the additional kwarg, default='regular', if you don't want 
italics.
All this is with text.usetex=False (the default).
> 
> second question, when using TeX, I tried the following TeX command in labels:
> plt.annotate(r"\frac{\sigma}{\sqrt{\mu}}", ....) but it complains that
> "not all arguments converted during string formatting" -- but it seems
> like correct TeX to me. if I try r"\frac{1}{2}" then it works, but
> using \sigma and \sqrt inside breaks it.. any idea how to fix this?
This is working for me with usetex=False or True but including dollar 
signs to signal the use of mathtext (or TeX) parsing.
Eric
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /