You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One is that \boldsymbol is actually an extension provided by the amssymb/amsmath packages. mathtext generally just supports things in the TeX core (though some concessions have been made to features from popular third-party packages and the ams stuff certainly qualifies as popular).
The other problem is really one of font availability. The computer modern truetype fonts that ship with matplotlib (the "Bakoma" fonts), simply don't contain those symbols. We would need to find another computer modern truetype distribution that had more stuff. And chances are it will have a different encoding, so the character map in _mathtext_data.py would have to be updated.
However, the STIX fonts do have a lot of the Greek symbols in bold, so you can set the rcParam 'mathtext.fontset' to 'stix' and then do:
$\mathbf{ \psi }$
(Of course, if you really want to use Computer Modern to match the rest of your paper, this is less than ideal.).
It is a modernized math font for the Computer Modern family in the OpenType format. I already used it in XeLaTeX but I guess one could use it for matplotlib mathtext as well..
On first glance (I just opened it up in fontforge) it seems that Latin Modern follows the Unicode mapping, which would be nice because we could drop our Bakoma-specific mapping and share the Unicode mapping that's already used for the STIX fonts. This should, if nothing else, be less code to maintain.
@mdboom - showing my naïvety here, but is there a font which could render the text inside a mathtex block (wrapped by \mathrm{}) the same as text outside of a mathtex block?
The font used in the \mathrm{} section can be configured using the mathtext.rm rcParam. So you can set that to the same value as font.family if you want them to match. By default, it chooses the font designed to work with the rest of the math content, so Computer Modern Roman when mathtext.fontset is set to cm.
I mispoke -- mathtext.rm only gets used if mathtext.fontset is custom... So I'm not sure that works in conjunction with the Bakoma/Computer Modern fonts. I may want to add that as a bug that I can tackle when I tackle other things related to our math fonts.
Thanks Mike that helped me along the way, to match the mathtex font to the normal text font (in my case at least):
...
matplotlib.rcParams['mathtext.rm'] = 'Bitstream Vera Sans'
matplotlib.rcParams['mathtext.fontset'] = 'custom'
matplotlib.rcParams['mathtext.cal'] = 'Bitstream Vera Sans'
...
ax.xaxis.label.set_text(r'$\mathrm{Foobar}\ /\ wibble\ bar^{-1}$')
There is so much font capability in mpl that isn't really documented - are fonts your forte? Are there improvements to the font systems that you would like to see implemented before we write a font chapter in the documentation?
Seems like there are really two issues here: one for the original \boldsymbol request and one for a broader font documentation request
The latter certainly stands, but where do we stand on \boldsymbol? Is this a can't fix (i.e., what's our gut sense on whether or not a suitable font exists?)?
The XITS fonts (derived work from STIX that did not deliver for years and years and years) contains both a regular and a bold variant.
The Polish TeX user group GUST is working on a number of free Unicode math fonts and some of them come or will come in a bold variant. Even the non-bold fonts contain a number of bold symbols inside the "bold" Unicode slots. Supporting "bold mathematical ..." is certainly worth looking into.
There are also some commercial fonts like Lucida with a special bold font.
What I don't know is how much effort is needed to get the OpenType Math working in matplotlib.
We no longer use Vera + CM fonts, but DejaVu fonts in all cases (by default.) These fonts contain bold-italic symbols here:
so there is no need for extra fonts.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
\perp won't go bold for me using this and when I use Latex then nothing will go bold and the font looks worse/inconsistent with other plots. Please help.
Activity
pelson commentedon Oct 12, 2012
Love it! Thanks for the squeak! :-)
mdboom commentedon Oct 12, 2012
There's two problems with doing this.
One is that
\boldsymbolis actually an extension provided by the amssymb/amsmath packages. mathtext generally just supports things in the TeX core (though some concessions have been made to features from popular third-party packages and the ams stuff certainly qualifies as popular).The other problem is really one of font availability. The computer modern truetype fonts that ship with matplotlib (the "Bakoma" fonts), simply don't contain those symbols. We would need to find another computer modern truetype distribution that had more stuff. And chances are it will have a different encoding, so the character map in
_mathtext_data.pywould have to be updated.However, the STIX fonts do have a lot of the Greek symbols in bold, so you can set the rcParam 'mathtext.fontset' to 'stix' and then do:
(Of course, if you really want to use Computer Modern to match the rest of your paper, this is less than ideal.).
pwuertz commentedon Oct 12, 2012
I recently came across the "Latin Modern Math" project when I was looking for math fonts with unicode support:
http://www.gust.org.pl/projects/e-foundry/lm-math
It is a modernized math font for the Computer Modern family in the OpenType format. I already used it in XeLaTeX but I guess one could use it for matplotlib mathtext as well..
pelson commentedon Mar 25, 2013
@pwuertz - sounds interesting. Can you think of any drawbacks to this?
mdboom commentedon Mar 25, 2013
On first glance (I just opened it up in
fontforge) it seems that Latin Modern follows the Unicode mapping, which would be nice because we could drop our Bakoma-specific mapping and share the Unicode mapping that's already used for the STIX fonts. This should, if nothing else, be less code to maintain.pelson commentedon Mar 26, 2013
@mdboom - showing my naïvety here, but is there a font which could render the text inside a mathtex block (wrapped by
\mathrm{}) the same as text outside of a mathtex block?mdboom commentedon Mar 26, 2013
The font used in the
\mathrm{}section can be configured using themathtext.rmrcParam. So you can set that to the same value asfont.familyif you want them to match. By default, it chooses the font designed to work with the rest of the math content, so Computer Modern Roman whenmathtext.fontsetis set tocm.mdboom commentedon Mar 26, 2013
I mispoke --
mathtext.rmonly gets used ifmathtext.fontsetiscustom... So I'm not sure that works in conjunction with the Bakoma/Computer Modern fonts. I may want to add that as a bug that I can tackle when I tackle other things related to our math fonts.pelson commentedon Mar 27, 2013
Thanks Mike that helped me along the way, to match the mathtex font to the normal text font (in my case at least):
There is so much font capability in mpl that isn't really documented - are fonts your forte? Are there improvements to the font systems that you would like to see implemented before we write a font chapter in the documentation?
petehuang commentedon Dec 31, 2016
Seems like there are really two issues here: one for the original
\boldsymbolrequest and one for a broader font documentation requestThe latter certainly stands, but where do we stand on
\boldsymbol? Is this a can't fix (i.e., what's our gut sense on whether or not a suitable font exists?)?mojca commentedon Jan 1, 2017
The XITS fonts (derived work from STIX that did not deliver for years and years and years) contains both a regular and a bold variant.
The Polish TeX user group GUST is working on a number of free Unicode math fonts and some of them come or will come in a bold variant. Even the non-bold fonts contain a number of bold symbols inside the "bold" Unicode slots. Supporting "bold mathematical ..." is certainly worth looking into.
There are also some commercial fonts like Lucida with a special bold font.
What I don't know is how much effort is needed to get the OpenType Math working in matplotlib.
QuLogic commentedon Jan 2, 2017
We no longer use Vera + CM fonts, but DejaVu fonts in all cases (by default.) These fonts contain bold-italic symbols here:

so there is no need for extra fonts.
mojca commentedon Jan 2, 2017
There is also http://www.gust.org.pl/projects/e-foundry/tex-gyre-dejavu-math. If bold symbols from the Unicode math repertoire is going to be used, it should be pretty straightforward to switch to a different Unicode Math OTF font.
github-actions commentedon Feb 27, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
mojca commentedon Feb 27, 2023
The request is still valid/wanted.
egnerney commentedon Jul 21, 2024
\perp won't go bold for me using this and when I use Latex then nothing will go bold and the font looks worse/inconsistent with other plots. Please help.