On Oct 30, 2013, at 10:14, Neal Becker <ndbeck...@gmail.com> wrote:

> I have a blue line plot and a green line plot.  I'd like to add some figtext 
> at 
> the bottom, and I'd like the text colors to match the plot colors.  So I'd 
> have 
> some text in blue and some in green.
> 
> figtext only allows one color
> 
> I could use 2 figtext, but then I have to manually find coordinate positions 
> for 
> the text.  That's ugly.
> 
> It would be nice if we had a TeX-like approach, where I could create a green 
> text object and a blue text object, then assemble them by stacking boxes.
> 
> Any ideas?

I'm not sure it's the best approach, but I've used HPacker (or VPacker if you 
want more than one line) to do this

from matplotlib.offsetbox import HPacker
from matplotlib.offsetbox import VPacker
from matplotlib.offsetbox import TextArea
from matplotlib.offsetbox import AnchoredOffsetbox

plot([1,2,3,4,5])
wloc = TextArea('WIND XYZ=()', textprops=dict(color="r", size=12))
sloc = TextArea('SOHO XYZ=()', textprops=dict(color="k", size=18))
txt1 = HPacker(children=[wloc, sloc], align="baseline", pad=0, sep=12)
txt2 = VPacker(children=[wloc, sloc], align="baseline", pad=0, sep=30)
bbox = AnchoredOffsetbox(loc=1.0, pad=0, borderpad=0,
             bbox_to_anchor=(0.8, 0.10),
             bbox_transform=gca().transAxes,
             child=txt1,
             frameon=False)
gca().add_artist(bbox)
bbox = AnchoredOffsetbox(loc=1.0, pad=0, borderpad=0,
             bbox_to_anchor=(0.4, 0.80),
             bbox_transform=gca().transAxes,
             child=txt2,
             frameon=False)
gca().add_artist(bbox)



------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to