Is there a way to have two colors of text on an axis label? I am trying to plot sales dollars and margin dollars on the same graph in different colors. That works well enough but I'm having a hard time labeling the yaxis
plot_date(dates,units,visible = False)
bar(dates,sales,width=5.0,color = salesColor)
bar(dates,margin,width=5.0,color = marginColor)
ylabel("Sales $\nMargin $",color=salesColor)
gets me "Sales $" in the proper color but I can't figure out if it is possible to have "Margin $" in its color as well.
Thanks!
John
I don't think it's currently possible in any sort of "automatic" way. There have been thoughts of adding support for multiple y labels in the past, but that's a medium-sized chunk of work.
However, as a roundabout approach, you could add figure text:
t = gcf().text(0.5, 0.05, "Margin $",
horizontalalignment='center', color=marginColor)
The location of the text is specified relative to the whole figure (in the range 0-1). It may take some tweaking to get the positioning right.
BTW -- I don't know if you're using 0.90 or 0.91. In 0.91, since the string "Sales \\nMargin " has two dollar-signs, the section between them will be treated as math notation. To avoid that, you can escape the dollar signs, i.e. "Sales \\$\nMargin \\$".
Cheers,
Mike
John Harrison wrote:
ยทยทยท
Is there a way to have two colors of text on an axis label? I am trying to plot sales dollars and margin dollars on the same graph in different colors. That works well enough but I'm having a hard time labeling the yaxis
plot_date(dates,units,visible = False)
bar(dates,sales,width=5.0,color = salesColor)
bar(dates,margin,width=5.0,color = marginColor)
ylabel("Sales \\nMargin ",color=salesColor)
gets me "Sales " in the proper color but I can't figure out if it is possible to have "Margin " in its color as well.
Thanks!
John
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA