Thanks Jeffrey. That clarifies why \mathcal works everywhere: it's
handled by matplotlib's own parser. In contrast, for \textcolor, a call
to TeX via the lines
from matplotlib import rc
rc('text', usetex=True)
rc('text.latex', preamble='\usepackage{color}')
is necessary.
I still don't get \texcolor to work for anything other than ps. This is
inconvenient as I'm not used to PostScript; for one thing, when I need
the plot to be 'big' [using plt.figure(figsize=(13.0, 13.0))], the ps
file created seems to be an A4 format with the plot not fitting onto
it: it is shown only partially. In contrast, for pdf or svg output, the
page size is adapted to the figure size -- but in those cases
\textcolor does not work...
On Wed 14 Aug 2013 03:34:13 CEST, Jeffrey Spencer wrote:
> Have a look here why Mathcal works in all backends:
>
> http://matplotlib.org/users/mathtext.html
>
> They give an example for an interactive backend which means it would
> work with any output format in the link you provided. Could also use
> \textcolor for .pdf output as well since the text rendering would use
> TeX as well but this wouldn't get you SVG.
>
> On Tue, Aug 13, 2013 at 9:00 PM, Xiha <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hello,
>
> I am trying to color-highlight parts of a figure title. I got it
> to work via the second ('non-interactive') solution given here
>
> <http://stackoverflow.com/questions/9169052/partial-coloring-of-text-in-matplotlib>,
> using TeX's \textcolor. It has the advantage (over the first
> solution) that you can use .xlabel(), .title() etc. as usual.
>
> However the limitation stated is that it only works when saving
> the plot as a PostScript file. I'm finding this to be true: the
> coloring does not appear when plotting to the screen rather than
> to a file (as with .show()), nor when using matplotlib.use('SVG')
> or matplotlib.use('AGG') to get svg or png output (which I would
> prefer). This is so even though other 'fancy' TeX commands like
> \mathcal do seem to work in all output options.
>
> I am only minimally acquainted with (La)TeX, and fairly new to
> Python and matplotlib too, so I don't quite grasp what is going on
> here, and whether it is worth digging deeper to try and make it
> work. So: why is there a difference in success between using
> (e.g.) \mathcal versus \textcolor over different output options?
>
> Many thanks!
> ||
>
>
> ------------------------------------------------------------------------------
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users