title: Plotting "None" values in Matplotlib
body: <p>I have a database which stores values every minute using a timestamp and a value for that timestamp. Sometimes the value is None. I have to plot these values using matplotlib.</p>
  
  <p>I have tried passing simply the None value but when plotting, i get this error: 
  "raise TypeError("{val!r} is not a string".format(val=val))
  TypeError: None is not a string" so i ended up just replacing the None values with an empty string "". But this ends up plotting dots as "0" values which is incorrect for my purpose. I would like these values not to be represented.</p>
  
  <p>My data is stored as dictionaries with list values.</p>
  
  <p>This is my code:</p>
  
  <pre><code>from __future__ import unicode_literals
  from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
  from matplotlib.figure import Figure
  from PyQt5 import QtWidgets, QtCore
  import sys
  import datetime
  import numpy
  
  
  class MyMplCanvas(FigureCanvas):
      def __init__(self, parent=None, width=5, height=4, dpi=100):
          fig = Figure(figsize=(width, height), dpi=dpi)
          self.axes = fig.add_subplot(111)
  
          FigureCanvas.__init__(self, fig)
          self.setParent(parent)
  
          FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
          FigureCanvas.updateGeometry(self)
  
      def compute_initial_figure(self):
          pass
  
  
  class MyDynamicMplCanvas(MyMplCanvas):
      def __init__(self, *args, **kwargs):
          MyMplCanvas.__init__(self, *args, **kwargs)
          self.lines = []
          self.labels = []
          self.update_figure()
  
      def update_figure(self):
          processed_numeric_values = {'0022FF0000000680_6': ['16.97', '16.97', '16.97', '', '16.97', '16.97', '16.97', '16.97'], '0022FF0000000680_7': ['16.97', '16.97', '16.97', '', '16.97', '16.97', '16.97', '16.97'], '0022FF0000000680_13': ['1.00', '1.00', '1.00', '', '1.00', '1.00', '1.00', '1.00'], '0022FF0000000680_14': ['0.99', '0.99', '0.99', '', '1.00', '1.00', '1.00', '0.99']}
  
          processed_time_values = {'0022FF0000000680_6': [datetime.datetime(2018, 9, 3, 9, 23), datetime.datetime(2018, 9, 3, 9, 24), datetime.datetime(2018, 9, 3, 9, 25), datetime.datetime(2018, 9, 3, 9, 26), datetime.datetime(2018, 9, 3, 9, 27), datetime.datetime(2018, 9, 3, 9, 28), datetime.datetime(2018, 9, 3, 9, 29), datetime.datetime(2018, 9, 3, 9, 30)], '0022FF0000000680_7': [datetime.datetime(2018, 9, 3, 9, 23), datetime.datetime(2018, 9, 3, 9, 24), datetime.datetime(2018, 9, 3, 9, 25), datetime.datetime(2018, 9, 3, 9, 26), datetime.datetime(2018, 9, 3, 9, 27), datetime.datetime(2018, 9, 3, 9, 28), datetime.datetime(2018, 9, 3, 9, 29), datetime.datetime(2018, 9, 3, 9, 30)], '0022FF0000000680_13': [datetime.datetime(2018, 9, 3, 9, 23), datetime.datetime(2018, 9, 3, 9, 24), datetime.datetime(2018, 9, 3, 9, 25), datetime.datetime(2018, 9, 3, 9, 26), datetime.datetime(2018, 9, 3, 9, 27), datetime.datetime(2018, 9, 3, 9, 28), datetime.datetime(2018, 9, 3, 9, 29), datetime.datetime(2018, 9, 3, 9, 30)], '0022FF0000000680_14': [datetime.datetime(2018, 9, 3, 9, 23), datetime.datetime(2018, 9, 3, 9, 24), datetime.datetime(2018, 9, 3, 9, 25), datetime.datetime(2018, 9, 3, 9, 26), datetime.datetime(2018, 9, 3, 9, 27), datetime.datetime(2018, 9, 3, 9, 28), datetime.datetime(2018, 9, 3, 9, 29), datetime.datetime(2018, 9, 3, 9, 30)]}
  
          for eui_attr in processed_numeric_values.keys():
              line, = self.axes.plot(numpy.array(processed_time_values[eui_attr]),
                                 numpy.array(processed_numeric_values[eui_attr]),
                                 visible=True,
                                 marker='o', markersize=5, lw=2, label=eui_attr)
          self.labels.append(eui_attr)
          self.lines.append(line)
          if self.labels:
              self.axes.legend(loc=1, ncol=2, fontsize='xx-small', frameon=True, fancybox=True, facecolor=(0.7, 0.7, 0.7))
          self.draw()
  
  class ApplicationWindow(QtWidgets.QMainWindow):
      def __init__(self):
          QtWidgets.QMainWindow.__init__(self)
          self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
          self.setWindowTitle("application main window")
  
          self.main_widget = QtWidgets.QWidget(self)
  
          l = QtWidgets.QVBoxLayout(self.main_widget)
          dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100)
          l.addWidget(dc)
  
          self.setCentralWidget(self.main_widget)
  
          self.statusBar().showMessage("All hail matplotlib!", 2000)
  
  
  qApp = QtWidgets.QApplication(sys.argv)
  aw = ApplicationWindow()
  aw.show()
  sys.exit(qApp.exec_())
  #qApp.exec_()
  </code></pre>
  
  <p>This is what i get now: <a href="https://i.stack.imgur.com/xj76V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xj76V.png" alt="enter image description here"></a></p>
  
  <p>This is what i want to achieve: <a href="https://i.stack.imgur.com/g4D2N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g4D2N.png" alt="enter image description here"></a></p>
  
  <p>I would like to maintain the dictionaries because they are part of a more complex code, just to replace the "" with None values so they are not interpreted as "0" values.</p>
  
  <p>Is there any way to do this? </p>
  
  <p>EDIT:</p>
  
  <p>The data dictionaries are structured like this:</p>
  
  <pre><code>processed_numeric_values = {'0022FF0000000680_6': [numeric_values], '0022FF0000000680_7': [numric_values], '0022FF0000000680_13': [numeric_values], '0022FF0000000680_14': [numeric_values]}
  
  processed_time_values = {'0022FF0000000680_6': [datetime_values], '0022FF0000000680_7': [datetime_values], '0022FF0000000680_13': [datetime_values], '0022FF0000000680_14': [datetime_values]}
  </code></pre>
  
  <p>The dictionaries contain the same keys and each key represents one line in the chart. The processed_numeric_values dictionary represents the data on the Y axis and processed_time_values dictionary represents the data on the X axis.</p>