I have a multicolor bar chart that I create like this:
bar(dates*4, b3 + b2 + b1 + b0,
color=(['#9E73C1']*len(dates) + ['#A6DE62']*len(dates)
+ ['#F35E5A']*len(dates) + ['#4992DE']*len(dates)),
width=4)
How can I create a legend for this?
leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
Shows the same color for each legend box, presumably because it's the
last color used in drawing the "line" in my bar chart.
~jon
For the record, I also just tried
bar(dates, b3, color='#9E73C1', width=4)
bar(dates, b2, color='#A6DE62', width=4)
bar(dates, b1, color='#F35E5A', width=4)
bar(dates, b0, color='#4992DE', width=4)
leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
And got the same results. (I had thought that multiple bar commands
would replace, rather than stack, on a given axis.)
~jon
···
On Thu, Sep 11, 2008 at 1:20 PM, Jonathon Anderson <janderso@...2148...> wrote:
I have a multicolor bar chart that I create like this:
bar(dates*4, b3 + b2 + b1 + b0,
color=(['#9E73C1']*len(dates) + ['#A6DE62']*len(dates)
+ ['#F35E5A']*len(dates) + ['#4992DE']*len(dates)),
width=4)
How can I create a legend for this?
leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
Shows the same color for each legend box, presumably because it's the
last color used in drawing the "line" in my bar chart.
~jon
I eventually did it with
b3l = bar(dates, b3, color='#9E73C1', width=4)
b2l = bar(dates, b2, color='#A6DE62', width=4)
b1l = bar(dates, b1, color='#F35E5A', width=4)
b0l = bar(dates, b0, color='#4992DE', width=4)
leg = legend([b3l[0], b2l[0], b1l[0], b0l[0]], ["98,304 -
163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
but I would be interested in hearing a better way.
~jon
···
On Thu, Sep 11, 2008 at 1:28 PM, Jonathon Anderson <janderso@...2148...> wrote:
For the record, I also just tried
bar(dates, b3, color='#9E73C1', width=4)
bar(dates, b2, color='#A6DE62', width=4)
bar(dates, b1, color='#F35E5A', width=4)
bar(dates, b0, color='#4992DE', width=4)
leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
And got the same results. (I had thought that multiple bar commands
would replace, rather than stack, on a given axis.)
~jon
On Thu, Sep 11, 2008 at 1:20 PM, Jonathon Anderson > <janderso@...2148...> wrote:
I have a multicolor bar chart that I create like this:
bar(dates*4, b3 + b2 + b1 + b0,
color=(['#9E73C1']*len(dates) + ['#A6DE62']*len(dates)
+ ['#F35E5A']*len(dates) + ['#4992DE']*len(dates)),
width=4)
How can I create a legend for this?
leg = legend(["98,304 - 163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
Shows the same color for each legend box, presumably because it's the
last color used in drawing the "line" in my bar chart.
~jon
Sorry to be so late in responding -- I missed your earlier posts. The
method you found is the suggested one.
JDH
···
On Thu, Sep 11, 2008 at 1:33 PM, Jonathon Anderson <janderso@...2148...> wrote:
I eventually did it with
b3l = bar(dates, b3, color='#9E73C1', width=4)
b2l = bar(dates, b2, color='#A6DE62', width=4)
b1l = bar(dates, b1, color='#F35E5A', width=4)
b0l = bar(dates, b0, color='#4992DE', width=4)
leg = legend([b3l[0], b2l[0], b1l[0], b0l[0]], ["98,304 -
163,840 Cores", "32768 - 98,303 Cores",
"8,192 - 32,767 Cores", "0 - 8,191 Cores"],
loc="upper left", shadow=True)
but I would be interested in hearing a better way.