title: How to plot bar graph interactively based on value of dropdown widget in bokeh python?
body: <p>I want to plot the bar graph based value of dropdown widget.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>import pandas as pd
  from bokeh.io import output_file, show
  from bokeh.layouts import widgetbox
  from bokeh.models.widgets import Dropdown
  from bokeh.plotting import curdoc
  from bokeh.charts import Bar, output_file,output_server, show #use output_notebook to visualize it in notebook
  
  
  df=pd.DataFrame({'item':["item1","item2","item2","item1","item1","item2"],'value':[4,8,3,5,7,2]})
  
  menu = [("item1", "item1"), ("item2", "item2")]
  dropdown = Dropdown(label="Dropdown button", button_type="warning", menu=menu)
  
  
  def function_to_call(attr, old, new):
  
      df=df[df['item']==dropdown.value]    
      p = Bar(df, title="Bar Chart Example", xlabel='x', ylabel='values', width=400, height=400)
      output_server()    
      show(p)
  
  dropdown.on_change('value', function_to_call)
  
  curdoc().add_root(dropdown)
  </code></pre>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>I am getting the flowing error "UnboundLocalError: local variable '<strong>df</strong>' referenced before assignment" eventhough df is already created.</li>
  <li>How to plot the bar graph in the webpage below the dropdown? What is the syntax to display it after issue in 1. is resolved?</li>
  </ol>