On Oct 7, 2016, at 12:22 PM, Matt Tenenbaum <matt.tenenbaum@rockyou.com> wrote:
Failing an "official" way of providing a collection of legend-labels (which I don't see from a quick scan of the docs), you could just plot the lines individually. In what follows, I'm assuming that iterating over `StateMktYear` produces the (string) names, since that's how you're using it. If not, you may want to zip over the column-names or whatever else is appropriate depending on the type of `StateMktYear`.
Code is untested, but should be in the ballpark.
p = figure(width=600, height=300)
# This replaces the call to p.multi_line()...
colors = ['green','red','blue','magenta','black']
for color, name in zip(colors, StateMktYear):
p.line(x=StateMktYear.index.values,
y=StateMktYear[name].values,
legend=name, color=color, line_width=2)
p.left[0].formatter.use_scientific = False
# p.legend='abc'
# p.legend.location='bottom_left'
p.axis.axis_label_text_font_size='14pt'
p.axis.axis_label_text_font='Times'
p.axis.major_label_text_font='Times'
p.xaxis.ticker=FixedTicker(ticks=[2012,2013,2014])
p.title='Demand Across Years'
p.axis.major_label_text_color='Black'
p.xaxis.axis_label='Year'
p.yaxis.axis_label='Demand'
show(p)
-mt
On Fri, Oct 7, 2016 at 8:14 AM, <spg2731476@gmail.com> wrote:
I am struggling hard to get legend on top of the multi line plot.
Here is my code and output. I tried many things however could not succeed. Please help me in resolving this issue.
import pandas as pd
import numpy as np
from bokeh.plotting import figure, show, output_file
from bokeh.models import FixedTicker
numlines=len(StateMktYear.
columns)
p = figure(width=600, height=300)
p.multi_line(xs=[StateMktYear.
index.values]*numlines,
ys=[StateMktYear[name].values for name in StateMktYear],
color=['green','red','blue','
magenta','black'],
line_width=2)
p.left[0].formatter.use_
scientific = False
# p.legend='abc'
# p.legend.location='bottom_
left'
p.axis.axis_label_text_font_
size='14pt'
p.axis.axis_label_text_font='
Times'
p.axis.major_label_text_font='
Times'
p.xaxis.ticker=FixedTicker(
ticks=[2012,2013,2014])
p.title='Demand Across Years'
p.axis.major_label_text_color=
'Black'
p.xaxis.axis_label='Year'
p.yaxis.axis_label='Demand'
show(p)
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/010b2e60-3a03-4be4-8b38-27aab9cf5e8c%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CA%2BZuXfOCkFAGU9dj1p_d_K4DDdSHS7qPQHZgGTmgHhmkAF1WiQ%40mail.gmail.com\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.