title: TypeError: '<' not supported between instances of 'float' and 'NoneType'
body: <p>I have the code below:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from scipy import stats
  import matplotlib.pyplot as plt
  import matplotlib.colors
  np.random.seed(12345)
  
  df = pd.DataFrame({"values":[np.random.normal(32000,200000,3650).mean(), 
                     np.random.normal(43000,100000,3650).mean(), 
                     np.random.normal(43500,140000,3650).mean(), 
                     np.random.normal(48000,70000,3650).mean()], 
                    "index":[1992,1993,1994,1995]})
  
  standarderrors1992 = stats.sem(np.random.normal(32000,200000,3650))
  standarderrors1993 = stats.sem(np.random.normal(43000,100000,3650))
  standarderrors1994 = stats.sem(np.random.normal(43500,140000,3650))
  standarderrors1995 = stats.sem(np.random.normal(48000,70000,3650)) 
  add1992 = 1.96*standarderrors1992
  add1993 = 1.96*standarderrors1993
  add1994 = 1.96*standarderrors1994 
  add1995 = 1.96*standarderrors1995
  mean1992 = np.random.normal(32000,200000,3650).mean()
  mean1993 = np.random.normal(43000,100000,3650).mean()
  mean1994 = np.random.normal(43500,140000,3650).mean()
  mean1995 = np.random.normal(48000,70000,3650).mean()
  labels = [1992,1993,1994,1995]
  add = [add1992,add1992,add1994,add1995]
  
  def onclick(event):
   plt.cla()
   plt.bar(df["index"].values,df["values"].values,align='center', alpha=0.5,yerr=add)
   plt.xticks(labels)
   plt.show()
   limit = event.ydata
   limits = []
   limits.append(limit)
   if len(limits) &gt;= 1:
      plt.gcf().canvas.mpl_disconnect(plt.gcf().canvas.mpl_connect('button_press_event', onclick))
   dict = {mean1992:add1992,mean1993:add1993,mean1994:add1994,mean1995:add1995}
   colourofbars = [] 
   for key,value in dict.items():
      if limits[0] &gt; (key+(value)):
          colour = 1 
          colourofbars.append(colour)
      elif limits[0] &lt; (key-(value)):
          colour = 0 
          colourofbars.append(colour)
      elif (limits[0] &lt; (key+(value))) and (limits[0] &gt; (key-(value))): 
          colour = ((key+(value))-limits[0])/((key+value)-(key-value)) 
          colourofbars.append(colour)
   df["colourofbars"] = colourofbars
   cmap = plt.cm.rainbow
   norm = matplotlib.colors.Normalize(vmin=min(df["colourofbars"].values),vmax=max(df["colourofbars"].values)). 
   plt.bar(df["index"].values,df["values"].values,color=cmap(norm(df["colourofbars"].values)),align='center', alpha=0.5,yerr=add)     
   plt.xticks(labels)
   plt.axhline(y=limits[0],linewidth=1, color='k')
   plt.title('Graph showing proportion of confidence interval lying above the threshold value',y=1.05)
   plt.ylabel('Possible Y-threshold values',labelpad=5)
   plt.xlabel('Year',labelpad=5)
   sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
   plt.gcf().colorbar(sm)
  
  plt.gcf().canvas.mpl_connect('button_press_event', onclick)
  </code></pre>
  
  <p>However, I keep getting the error:</p>
  
  <pre><code>*Traceback (most recent call last):
    File "/Users/name/untitled2/lib/python3.8/site-packages/matplotlib/cbook/__init__.py", line 196, in process
      func(*args, **kwargs)
    File "&lt;input&gt;", **line 42**, in onclick
  TypeError: '&lt;' not supported between instances of 'float' and 'NoneType'*
  </code></pre>
  
  <p>Could anyone give me a helping hand?</p>
  
  <p>The overall aim is to allow the user to <strong>select a Y-value by pressing on the bar graph.</strong> The colour of each bar should then change depending on what this Y-value is.</p>
  
  <p>When I enter the code into Pycharm twice in a row, it seems to work, which I find hard to understand? Perhaps there is something wrong with the part where I use .plt to plot the bar graph?</p>