From: David P. S. <dps...@ci...> - 2013-07-20 14:42:26
|
I find the default font used in matplotlib horrible. We should be able to do much better these days. One very interesting option, at least for standard (paper) publishing, is the STIX fonts, which is a Times-like font set promoted by several publishers. There are various options in matplotlib, such as matplotlib.rcParams["mathtext.fontset"], which allow the option "stix", but I have not been able to get it to work. Can anybody please help me with this -- what is required? I have the STIX otf or ttf installed on my Mac, but I don't seem to manage to get the LaTeX versions installed -- installing LaTeX fonts is *so* disgusting (is there some helper script for that?). Thanks and best wishes, David. -- Dr. David P. Sanders Profesor Titular "A" / Associate Professor Departamento de Física, Facultad de Ciencias Universidad Nacional Autónoma de México (UNAM) dps...@ci... http://sistemas.fciencias.unam.mx/~dsanders Cubículo / office: #414, 4o. piso del Depto. de Física Tel.: +52 55 5622 4965 |
From: David P. S. <dps...@ci...> - 2013-07-20 15:00:14
|
Example script for using mathtext.fontset: import matplotlib as mpl import numpy as np from matplotlib import pyplot as plt mpl.rcParams["mathtext.fontset"] = "stix" x = np.arange(-5, 5, 0.01) y = x*x plt.plot(x, y) plt.xlabel(r"$x$") plt.ylabel(r"$x^2$") plt.show() Apparently the axis labels are correctly rendered using STIX fonts, *but* in a bitmapped way (?). At least, on my retina screen the labels look fuzzy. How can I change also the tic labels to use STIX fonts? By the way, the following is a useful idiom to search for relevant parameters in the rcParams: [k for k in mpl.rcParams.keys() if 'font' in k] I think it would be useful to document this -- where would be a good place? Finally, could somebody please explain what 'rc' means? This does not seem like a good name to me. I know it comes from the UNIX world, but I couldn't find an explanation for 'rc' on Wikipedia. OK, I found it: http://www.catb.org/jargon/html/R/rc-file.html This is not good -- there is *no* reason to use the nomenclature 'rc'; this is just confusing for users who find it arcane and unwelcoming (I speak from experience). Could it not just be called mpl.parameters, or mpl.mpl_parameters, or something like that? Best, David On Sat, Jul 20, 2013 at 9:41 AM, David P. Sanders < dps...@ci...> wrote: > I find the default font used in matplotlib horrible. We should be able to > do much better these days. > > One very interesting option, at least for standard (paper) publishing, is > the STIX fonts, which is a Times-like font set promoted by several > publishers. > > There are various options in matplotlib, such as > matplotlib.rcParams["mathtext.fontset"], which allow the option "stix", > but I have not been able to get it to work. Can anybody please help me with > this -- what is required? > > I have the STIX otf or ttf installed on my Mac, but I don't seem to manage > to get the LaTeX versions installed -- installing LaTeX fonts is *so* > disgusting (is there some helper script for that?). > > Thanks and best wishes, > David. > > -- > Dr. David P. Sanders > > Profesor Titular "A" / Associate Professor > Departamento de Física, Facultad de Ciencias > Universidad Nacional Autónoma de México (UNAM) > > dps...@ci... > http://sistemas.fciencias.unam.mx/~dsanders > > Cubículo / office: #414, 4o. piso del Depto. de Física > > Tel.: +52 55 5622 4965 > -- Dr. David P. Sanders Profesor Titular "A" / Associate Professor Departamento de Física, Facultad de Ciencias Universidad Nacional Autónoma de México (UNAM) dps...@ci... http://sistemas.fciencias.unam.mx/~dsanders Cubículo / office: #414, 4o. piso del Depto. de Física Tel.: +52 55 5622 4965 |
From: Ignas A. <ani...@gm...> - 2013-07-21 09:50:49
|
On Saturday 20 July 2013 09:59:45 David P. Sanders wrote: > OK, I found it: > http://www.catb.org/jargon/html/R/rc-file.html > > This is not good -- there is *no* reason to use the nomenclature 'rc'; this > is just confusing for users who find it arcane and unwelcoming (I speak > from experience). > > Could it not just be called > mpl.parameters, or mpl.mpl_parameters, > or something like that? Hello, I was just wondering what is wrong with using the name rc (because it's just a convention how to name your variable)? It is still used quite widely on UNIX (and Mac OS is still a UNIX :)). Also, it is documented here: http://matplotlib.org/users/customizing.html I see your point though, in this document there isn't a single word, that the 'rcParams' stand more or less for the parameters which are initialised when matplotlib loads or starts plotting. Do not know if we should change this page to add some explanation, why we use *rc settings*. Ignas |
From: Michael D. <md...@st...> - 2013-07-22 13:40:42
|
On 07/20/2013 10:59 AM, David P. Sanders wrote: > > > By the way, the following is a useful idiom to search for relevant > parameters in the rcParams: > > [k for k in mpl.rcParams.keys() if 'font' in k] > > I think it would be useful to document this -- where would be a good > place? You might want to look at rcParams.find_all(). Mike |
From: Eric F. <ef...@ha...> - 2013-07-20 18:55:46
|
On 2013/07/20 4:41 AM, David P. Sanders wrote: > I find the default font used in matplotlib horrible. We should be able > to do much better these days. Which font is being used as default on your installation? And what are the characteristics that earn the rating of "horrible"? Eric |
From: Benjamin R. <ben...@ou...> - 2013-07-20 19:03:28
|
David, IIRC, we were just starting to investigate how to produce retina graphics. Perhaps you might be able to help Mike D and Michael de Hoon with there efforts because very few of us have retina displays. Cheers! Ben Root On Jul 20, 2013 10:43 AM, "David P. Sanders" <dps...@ci...> wrote: > I find the default font used in matplotlib horrible. We should be able to > do much better these days. > > One very interesting option, at least for standard (paper) publishing, is > the STIX fonts, which is a Times-like font set promoted by several > publishers. > > There are various options in matplotlib, such as > matplotlib.rcParams["mathtext.fontset"], which allow the option "stix", > but I have not been able to get it to work. Can anybody please help me with > this -- what is required? > > I have the STIX otf or ttf installed on my Mac, but I don't seem to manage > to get the LaTeX versions installed -- installing LaTeX fonts is *so* > disgusting (is there some helper script for that?). > > Thanks and best wishes, > David. > > -- > Dr. David P. Sanders > > Profesor Titular "A" / Associate Professor > Departamento de Física, Facultad de Ciencias > Universidad Nacional Autónoma de México (UNAM) > > dps...@ci... > http://sistemas.fciencias.unam.mx/~dsanders > > Cubículo / office: #414, 4o. piso del Depto. de Física > > Tel.: +52 55 5622 4965 > > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > > |
From: David P. S. <dps...@ci...> - 2013-07-21 08:09:12
|
On Sat, Jul 20, 2013 at 2:03 PM, Benjamin Root <ben...@ou...> wrote: > David, > > IIRC, we were just starting to investigate how to produce retina graphics. > Perhaps you might be able to help Mike D and Michael de Hoon with there > efforts because very few of us have retina displays. > Sure, I'm very happy to help. First let me return to the fonts issue. I had been misunderstanding the rcParams (this seems to be a recurring problem at the moment ;) - some new documentation is definitely required; I will try to get round to add it to my matplotlib.settings notebook). The fuzziness I referred to was indeed a retina issue, stemming from the fact *that the default output format is still PNG*. It seems to me that these days the default output should be SVG, which immediately resolves all retina issues!! (And a lot of other issues, it seems to me.) The current status of retina support is actually reasonable. There are two options: %load_ext retina %config InlineBackend.figure_format = 'retina' In the absence of tab completion for %load_ext and %config, and not understanding the code, I am not sure if these are synonyms or not. But the effect is to have PNGs produced with twice the vertical and horizontal resolution. (The problem comes if, for example, these are included in output sent to nbviewer, in which case they appear twice as large.) One STIX font question remains: How can I get the text of the tick labels and other things to also be in STIX? settings['font.family'] = 'stix' does not work, apparently. And could the default font finally be changed to something else? What are the licensing requirements for the font? Is it distributed with matplotlib, or how does it work? David. |
From: Eric F. <ef...@ha...> - 2013-07-21 18:49:03
|
On 2013/07/20 10:08 PM, David P. Sanders wrote: > The fuzziness I referred to was indeed a retina issue, stemming from the > fact *that the default output format is still PNG*. It seems to me that > these days the default output should be SVG, which immediately resolves > all retina issues!! (And a lot of other issues, it seems to me.) > David, A major problem with SVG output as default is that for image-type plots (e.g., pcolormesh) it yields enormous output that is very slow to render. The advantage of png is that although it is not optimal from a visual standpoint, it works reliably and predictably with everything. Therefore it is a sensible default. Eric |
From: Michael D. <md...@st...> - 2013-07-22 13:39:58
|
The STIX fonts are included with matplotlib, as the licensing permits this. We actually ship TTF versions of the fonts, converted from the original OTF files, since the built-in font rendering (i.e. when not using XeTeX etc.) does not support OTF. See MEP14 for a discussion of some of the gory details, if you're interested. On 07/21/2013 04:08 AM, David P. Sanders wrote: > > > > On Sat, Jul 20, 2013 at 2:03 PM, Benjamin Root <ben...@ou... > <mailto:ben...@ou...>> wrote: > > David, > > IIRC, we were just starting to investigate how to produce retina > graphics. Perhaps you might be able to help Mike D and Michael de > Hoon with there efforts because very few of us have retina displays. > > > Sure, I'm very happy to help. > First let me return to the fonts issue. > I had been misunderstanding the rcParams (this seems to be a recurring > problem at the moment ;) - some new documentation is definitely > required; I will try to get round to add it to my matplotlib.settings > notebook). > > The fuzziness I referred to was indeed a retina issue, stemming from > the fact *that the default output format is still PNG*. It seems to me > that these days the default output should be SVG, which immediately > resolves all retina issues!! (And a lot of other issues, it seems to me.) > > The current status of retina support is actually reasonable. There are > two options: > > %load_ext retina > %config InlineBackend.figure_format = 'retina' > > In the absence of tab completion for %load_ext and %config, and not > understanding the code, I am not sure if these are synonyms or not. > But the effect is to have PNGs produced with twice the vertical and > horizontal resolution. (The problem comes if, for example, these are > included in output sent to nbviewer, in which case they appear twice > as large.) So it appears the fuzziness is specific to the IPython notebook. I think at the Scipy sprints we determined that using the MacOSX backend directly that there were no issues with the retina display. Let's maybe file an issue with the IPython folks about this. Since there is already a retina display plugin in IPython, perhaps a dicussion should be started about autodetecting the retina case and switching it on in that case. (I have no idea if that's technically feasible -- I don't know how Safari etc. implement the retina support). BTW: This is IPython's PR where this was added: https://github.com/ipython/ipython/pull/3381 > > One STIX font question remains: How can I get the text of the tick > labels and other things to also be in STIX? > settings['font.family'] = 'stix' > does not work, apparently. STIX is designed to blend seamlessly with Times (New Roman), so you can set the default family to that. It might be worth discussing whether setting `math.fontset` to `stix` should do that by default. (It's tricky because it creates a dependency between different rcParams), but in the meantime, that is the best workaround. > > And could the default font finally be changed to something else? What > are the licensing requirements for the font? Is it distributed with > matplotlib, or how does it work? The default font is Bitstream Vera Sans. At the time it was chosen, it was the only really obvious option for an open source font. There are better options now -- it would need to be something not only freely redistibutable, but also open source (to meet Debian and RedHat requirements). I don't know if we need to change the default, so much as make it easier to change (a la Tony's PR #2236). If there is a way to distribute fonts along with styles, that would be killer. I also hope to support WebFonts (which would be "installation free") as part of my ongoing work on MEP14, so that will get better, too. Mike > > David. > > > > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > > > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel |
From: Ignas A. <ani...@gm...> - 2013-07-21 09:56:51
|
On Saturday 20 July 2013 09:41:58 David P. Sanders wrote: > I have the STIX otf or ttf installed on my Mac, but I don't seem to manage > to get the LaTeX versions installed -- installing LaTeX fonts is *so* > disgusting (is there some helper script for that?). There is a very good way to use otf and ttf fonts in LaTeX and matplotlib, which you might like: http://matplotlib.org/users/pgf.html With this method you can use LuaLaTeX, or XeLaTeX, both of which have options to load OTF or TTF fonts. This would be done via the LaTeX preamble in the .matplotlibrc file, which might be storred in the home directory on your Mac (just a guess, since I do not normally use matplotlib with a Mac). This might be a bit of a steep learning curve if you haven't done anything more serious with matplotlib, but you won't have to install the fonts, which, I must agree, *is* painful. Hope that helps, Ignas |