Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: konstellationen <konstellationen@gm...>  20100326 08:06:31
Attachments:
Message as HTML

Hi, I am making plots for a publication using matplotlib which requires the use of heavy fonts. I am rendering text in the graph with Latex, which has a limited capability to make fonts more heavy. I partially solved the problem using the \boldmath Latex command for the axislabels and text inside the plot (see attached figure). The only remaining text to be "bolden" are the tick labels. I can change their size via the xtick.labelsize rc parameter, but do not know how to make them heavier. Does anybody know what can be done to solve this? Any help would be appreciated!!!! Best, Daniel http://old.nabble.com/file/p28037900/m8.png  View this message in context: http://old.nabble.com/BoldLatexTickLabelstp28037900p28037900.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: Gökhan Sever <gokhansever@gm...>  20100326 14:51:48
Attachments:
Message as HTML

On Fri, Mar 26, 2010 at 3:06 AM, konstellationen <konstellationen@...>wrote: > Hi, I am making plots for a publication using matplotlib which requires the > use of heavy fonts. I am rendering text in the graph with Latex, which has a > limited capability to make fonts more heavy. I partially solved the problem > using the \boldmath Latex command for the axislabels and text inside the > plot (see attached figure). The only remaining text to be "bolden" are the > tick labels. I can change their size via the xtick.labelsize rc parameter, > but do not know how to make them heavier. Does anybody know what can be done > to solve this? Any help would be appreciated!!!! Best, Daniel >  > You can try: xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklabels, fontsize=14, weight='bold') setp(yticklabels, fontsize=14, weight='bold') Those are nice looking plots. It would be nice them to be shared on mpl's gallery or as an example :)  Gökhan 
From: konstellationen <konstellationen@gm...>  20100326 17:42:52

>>You can try: >>xticklabels = getp(gca(), 'xticklabels') >>yticklabels = getp(gca(), 'yticklabels') >>setp(xticklabels, fontsize=14, weight='bold') >>setp(yticklabels, fontsize=14, weight='bold') I've tried this, but since I've set rc('text', usetex=True), the ticklabels are only responsive to fontsize but not to weight. That is at least my experience. Am I doing something wrong? I've been trying to solve my problem by replacing the ticklabels with strings. I know this is a very inelegant workaround, but I am running out of ideas. I've tried two approaches that haven't worked successfully. (I don't get error messages, but nothing changes in the plot): Approach 1: x_labels = ['\boldmath $10^22$','\boldmath $10^23$','\boldmath $10^24$'] ax1.set_xticklabels(x_labels) Approach 2: Inspired by http://old.nabble.com/axisontopforbarhplottd26549035.html this post : ax1.xaxis.set_major_locator(ticker.FixedLocator(range(3))) ax1.xaxis.set_major_formatter(ticker.FixedFormatter(x_labels)) >>Those are nice looking plots. It would be nice them to be shared on mpl's >>gallery or as an example :) Thanks! I'd be happy to share my code with everyone. It is not very nicely written, but I can fix it up. What steps should I take? Everything I've learned is from examples. This is just an amalgamation of expressions I've found on the web. Cheers, Daniel  View this message in context: http://old.nabble.com/BoldLatexTickLabelstp28037900p28045728.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: Gökhan Sever <gokhansever@gm...>  20100326 20:27:53
Attachments:
Message as HTML

On Fri, Mar 26, 2010 at 12:42 PM, konstellationen <konstellationen@... > wrote: > > >>You can try: > > >>xticklabels = getp(gca(), 'xticklabels') > >>yticklabels = getp(gca(), 'yticklabels') > >>setp(xticklabels, fontsize=14, weight='bold') > >>setp(yticklabels, fontsize=14, weight='bold') > > I've tried this, but since I've set rc('text', usetex=True), the > ticklabels > are only responsive to fontsize but not to weight. That is at least my > experience. Am I doing something wrong? > > I've been trying to solve my problem by replacing the ticklabels with > strings. I know this is a very inelegant workaround, but I am running out > of > ideas. I've tried two approaches that haven't worked successfully. (I don't > get error messages, but nothing changes in the plot): > > Approach 1: > x_labels = ['\boldmath $10^22$','\boldmath $10^23$','\boldmath $10^24$'] > ax1.set_xticklabels(x_labels) > > Approach 2: > Inspired by > http://old.nabble.com/axisontopforbarhplottd26549035.html > this post : > > ax1.xaxis.set_major_locator(ticker.FixedLocator(range(3))) > ax1.xaxis.set_major_formatter(ticker.FixedFormatter(x_labels)) > Does it work with: plt.xticks((10**22, 10**23, 10**24), (r'$10^{22}$', r'$10^{23}$', r'$10^{24}$'), weight='extra bold') > > >>Those are nice looking plots. It would be nice them to be shared on mpl's > >>gallery or as an example :) > > Thanks! I'd be happy to share my code with everyone. It is not very nicely > written, but I can fix it up. What steps should I take? Everything I've > learned is from examples. This is just an amalgamation of expressions I've > found on the web. > > Cheers, Daniel > > Just prepare a selfrunning code, and add some documentation what is it good for. Later send an email either here or to mpldevel. Someone with commit access would be glad to include it in pylab_examples.  Gökhan 
From: Diakronik <fred.mailhot@gm...>  20100403 20:33:35

konstellationen wrote: > > Hi, > > I am making plots for a publication using matplotlib which requires the > use of heavy fonts. I am rendering text in the graph with Latex, which has > a limited capability to make fonts more heavy. I partially solved the > problem using the \boldmath Latex command for the axislabels and text > inside the plot (see attached figure). The only remaining text to be > "bolden" are the tick labels. I can change their size via the > xtick.labelsize rc parameter, but do not know how to make them heavier. > > Does anybody know what can be done to solve this? > > Any help would be appreciated!!!! > > Best, Daniel > > I ran into the same problem today trying to prepare figures for my thesis, and I figured out a way to do it...it's not pretty, but it works: import matplotlib.pyplt as plt tick_locs = range(start, stop, increment) plt.xticks(tick_locs, [r"$\mathbf{%s}$" % x for x in tick_locs]) Hope this helps!  View this message in context: http://old.nabble.com/BoldLatexTickLabelstp28037900p28129365.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: konstellationen <konstellationen@gm...>  20100410 01:15:38

For future reference, the solution proposed by Gökhan and Diakronik is to replace the Latex ticklabels with strings: >import matplotlib.pyplt as plt >tick_locs = range(start, stop, increment) >plt.xticks(tick_locs, [r"$\mathbf{%s}$" % x for x in tick_locs]) If you have twin x or y axes (my case), the solution I found was: (Note: this solution is essentially the same as the one above, with the distinction that every entry is set manually, which allows for more flexibility, but requires more work) >from mpl_toolkits.axes_grid.parasite_axes import SubplotHost >from matplotlib.pylab import * # For plotting graphs. >from matplotlib.pyplot import * >fig=figure(1) >host= SubplotHost(fig,111) >fig.add_subplot(host) >par=host.twiny() >host.axis["bottom"] >par.axis["top"] >hostv=[1e14,1e4,1.5,1.5] >host.axis(hostv) >parv=[1e8,1e2,1.5,0.5] >par.axis(parv) >host.set_xticks([1e14, ... ,1e4]) >x_labels = [r'\boldmath $10^{14} $', ... ,r'\boldmath $ $'] >host.set_xticklabels(x_labels) >par.set_xticks([1e8, ... ,1e2]) >parx_labels = [ r'\boldmath $10^{8}$', ... ,r'\boldmath $ $' ] >par.set_xticklabels(parx_labels) >host.set_yticks([1,0]) >y_labels = [r'\boldmath $1$', r'\boldmath $0$'] >host.set_yticklabels(y_labels) Result: http://old.nabble.com/file/p28199345/Picture%2B7.png  View this message in context: http://old.nabble.com/BoldLatexTickLabelstp28037900p28199345.html Sent from the matplotlib  users mailing list archive at Nabble.com. 
From: Friedrich Romstedt <friedrichromstedt@gm...>  20100419 13:52:42

http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.FuncFormatter 2010/4/10 konstellationen <konstellationen@...>: > > For future reference, the solution proposed by Gökhan and Diakronik is to > replace the Latex ticklabels with strings: > >>import matplotlib.pyplt as plt >>tick_locs = range(start, stop, increment) >>plt.xticks(tick_locs, [r"$\mathbf{%s}$" % x for x in tick_locs]) > > If you have twin x or y axes (my case), the solution I found was: > > (Note: this solution is essentially the same as the one above, with the > distinction that every entry is set manually, which allows for more > flexibility, but requires more work) > > >>from mpl_toolkits.axes_grid.parasite_axes import SubplotHost >>from matplotlib.pylab import * # For plotting graphs. >>from matplotlib.pyplot import * > >>fig=figure(1) >>host= SubplotHost(fig,111) >>fig.add_subplot(host) >>par=host.twiny() > >>host.axis["bottom"] >>par.axis["top"] > >>hostv=[1e14,1e4,1.5,1.5] >>host.axis(hostv) >>parv=[1e8,1e2,1.5,0.5] >>par.axis(parv) > >>host.set_xticks([1e14, ... ,1e4]) >>x_labels = [r'\boldmath $10^{14} $', ... ,r'\boldmath $ $'] >>host.set_xticklabels(x_labels) > >>par.set_xticks([1e8, ... ,1e2]) >>parx_labels = [ r'\boldmath $10^{8}$', ... ,r'\boldmath $ $' ] >>par.set_xticklabels(parx_labels) > >>host.set_yticks([1,0]) >>y_labels = [r'\boldmath $1$', r'\boldmath $0$'] >>host.set_yticklabels(y_labels) > > > Result: > > http://old.nabble.com/file/p28199345/Picture%2B7.png There is another technique based on the FuncFormatter or the FormatStrFormatter in matplotlib.ticker, see the link at the very top. It makes less efford when one can rely on the automatic ticking mechanism and when one has access to the axis (with i) instances. It is: To obtain mathformatted number output: >>> formatter = matplotlib.ticker.FormatStrFormatter('$%g$') >>> axes.xaxis.set_major_formatter(formatter) The most important is that one has no longer to set the tick locations manually. For exponential ticks, I would propose (but it's untested): >>> def exp_fmt(loc): exponent = numpy.round(numpy.log10(loc)) return '$10^%d$' % exponent >>> formatter = matplotlib.ticker.FuncFormatter(exp_fmt) >>> # And so on. Note that using r'$\mathbf{%g}$' makes, for me, no difference. It may be that one needs matplotlib.rc('text', usetex = True) to make also numbers bold by \mathbf{}, but iirc, also in LaTeX numbers are always plain, also in \mathbf{}. \boldmath$$ may be an exception from this rule. fwiw, Friedrich P.S.: I cannot test usetex = True at the moment, because I end up with the error 'Could not obtain dvipng version'. 
From: Michael Droettboom <mdroe@st...>  20100419 19:33:13

Friedrich Romstedt wrote: > 2010/4/19 Friedrich Romstedt <friedrichromstedt@...>: > > What is the advantage of using > matplotlib.ticker.ScalarFormatter(useMathText = True) then, when it's > typeset in outsidemath font anyway? > It's the only way to get superscripts (well, Unicode has superscript numerals, but the formatter doesn't currently use them). Mike  Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA 
From: Friedrich Romstedt <friedrichromstedt@gm...>  20100419 20:00:06

2010/4/19 Michael Droettboom <mdroe@...>: > Friedrich Romstedt wrote: >> >> What is the advantage of using >> matplotlib.ticker.ScalarFormatter(useMathText = True) then, when it's >> typeset in outsidemath font anyway? >> > > It's the only way to get superscripts (well, Unicode has superscript > numerals, but the formatter doesn't currently use them). Understood, so for the scientific notation? I.e., for the case when there is a \times<something> at the edge? (It's clear we're talking about ScalarFormatter.) I would like it very much if one could make *all* text in matplotlib figures be set in LaTeX font, for integration with LaTeX documents the figures are used in. Is this already possible? Friedrich 
From: Friedrich Romstedt <friedrichromstedt@gm...>  20100419 19:28:25

2010/4/19 Friedrich Romstedt <friedrichromstedt@...>: > http://matplotlib.sourceforge.net/api/ticker_api.html#matplotlib.ticker.FuncFormatter > For exponential ticks, I would propose (but it's untested): > >>>> def exp_fmt(loc): > exponent = numpy.round(numpy.log10(loc)) > return '$10^%d$' % exponent >>>> formatter = matplotlib.ticker.FuncFormatter(exp_fmt) >>>> # And so on. Well, as JJ pointed out recently, there is matplotlib.ticker.LogFormatterMathtext as a much better template to use ... Well, and even for scalar formatters, there is matplotlib.ticker.ScalarFormatter(useMathText = True) ... Shame on me! But it seems there is a small drawback: For nonrcusetex mode, \mathdefault{} is used, making the math typeset in the normal, outsidemath font (according to http://matplotlib.sourceforge.net/users/mathtext.html?highlight=mathdefault#fonts). What is the advantage of using matplotlib.ticker.ScalarFormatter(useMathText = True) then, when it's typeset in outsidemath font anyway? Friedrich 