title: Mark plot at specific x-axis point using seaborn
body: <p>I have been trying to fix this for hours now and I am really frustrated. The only thing I want to do is highlight my plot at the timepoints 2,6 and 10 (as shown in the image)<a href="https://i.stack.imgur.com/gZVTE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gZVTE.jpg" alt="light blue is where I want the highlights to be" /></a></p>
  <p>I want to create multiple plots (I have different features (y-axis) and groups (blacked out) for which I want these plots).</p>
  <p>This is my code:</p>
  <pre><code>for elem in mylist:
      for title in myotherlist:
          to_mark = [False, True, False, False, False, True, False, False, False, True]
          to_mark2 = [1,5,9]
  
          sns.lineplot(data=data, x=&quot;time_point&quot;, y=elem, hue=title, err_style=&quot;bars&quot;, ci=95, markevery = [1,5,9], marker = '|', markersize=20, fillstyle='none', markeredgewidth=1.5, markeredgecolor='black')
          plt.savefig(file_path)
          plt.clf()
          plt.cla()
          plt.close()
  </code></pre>
  <p>I tried</p>
  <pre><code>markevery = to_mark and
  markevery = to_mark2
  </code></pre>
  <p>But nothing seems to work. I get the error message</p>
  <pre><code>    IndexError                                Traceback (most recent call last)
      ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery,     tpath, affine, ax_transform)
      215         try:
  --&gt; 216             return Path(verts[markevery],
      217                     _slice_or_none(codes, markevery))
  
  IndexError: index 5 is out of bounds for axis 0 with size 2
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-318-7c71faf85be6&gt; in &lt;module&gt;()
       65 
       66         #plt.plot()
  ---&gt; 67         plt.savefig(file_path)
       68         #with open(file_path, 'wb') as f:
       69             #plt.savefig(file_path)
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\pyplot.py in savefig(*args, **kwargs)
      708 def savefig(*args, **kwargs):
      709     fig = gcf()
  --&gt; 710     res = fig.savefig(*args, **kwargs)
      711     fig.canvas.draw_idle()   # need this if 'transparent=True' to reset colors
      712     return res
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\figure.py in savefig(self, fname, **kwargs)
     2033             self.set_frameon(frameon)
     2034 
  -&gt; 2035         self.canvas.print_figure(fname, **kwargs)
     2036 
     2037         if frameon:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
     2261                 orientation=orientation,
     2262                 bbox_inches_restore=_bbox_inches_restore,
  -&gt; 2263                 **kwargs)
     2264         finally:
     2265             if bbox_inches and restore_bbox:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_pdf.py in print_pdf(self, filename, **kwargs)
     2584                 RendererPdf(file, image_dpi, height, width),
     2585                 bbox_inches_restore=_bbox_inches_restore)
  -&gt; 2586             self.figure.draw(renderer)
     2587             renderer.finalize()
     2588             if not isinstance(filename, PdfPages):
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\figure.py in draw(self, renderer)
     1473 
     1474             mimage._draw_list_compositing_images(
  -&gt; 1475                 renderer, self, artists, self.suppressComposite)
     1476 
     1477             renderer.close_group('figure')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
     2605             renderer.stop_rasterizing()
     2606 
  -&gt; 2607         mimage._draw_list_compositing_images(renderer, self, artists)
     2608 
     2609         renderer.close_group('axes')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in draw(self, renderer)
      809                 if markevery is not None:
      810                     subsampled = _mark_every_path(markevery, tpath,
  --&gt; 811                                                   affine, self.axes.transAxes)
      812                 else:
      813                     subsampled = tpath
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      220             raise ValueError('`markevery` is iterable but '
      221                 'not a valid form of numpy fancy indexing; '
  --&gt; 222                 'markevery=%s' % (markevery,))
      223     else:
      224         raise ValueError('Value of `markevery` is not '
  
  ValueError: `markevery` is iterable but not a valid form of numpy fancy indexing; markevery=[1, 5, 9]
  
  ---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      215         try:
  --&gt; 216             return Path(verts[markevery],
      217                     _slice_or_none(codes, markevery))
  
  IndexError: index 5 is out of bounds for axis 0 with size 2
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call last)
  ~\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
      330                 pass
      331             else:
  --&gt; 332                 return printer(obj)
      333             # Finally look for special method names
      334             method = get_real_method(obj, self.print_method)
  
  ~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in &lt;lambda&gt;(fig)
      235 
      236     if 'png' in formats:
  --&gt; 237         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
      238     if 'retina' in formats or 'png2x' in formats:
      239         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
  
  ~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
      119 
      120     bytes_io = BytesIO()
  --&gt; 121     fig.canvas.print_figure(bytes_io, **kw)
      122     data = bytes_io.getvalue()
      123     if fmt == 'svg':
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
     2210                     orientation=orientation,
     2211                     dryrun=True,
  -&gt; 2212                     **kwargs)
     2213                 renderer = self.figure._cachedRenderer
     2214                 bbox_inches = self.figure.get_tightbbox(renderer)
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
      511 
      512     def print_png(self, filename_or_obj, *args, **kwargs):
  --&gt; 513         FigureCanvasAgg.draw(self)
      514         renderer = self.get_renderer()
      515         original_dpi = renderer.dpi
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in draw(self)
      431             # if toolbar:
      432             #     toolbar.set_cursor(cursors.WAIT)
  --&gt; 433             self.figure.draw(self.renderer)
      434             # A GUI class may be need to update a window using this draw, so
      435             # don't forget to call the superclass.
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\figure.py in draw(self, renderer)
     1473 
     1474             mimage._draw_list_compositing_images(
  -&gt; 1475                 renderer, self, artists, self.suppressComposite)
     1476 
     1477             renderer.close_group('figure')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
     2605             renderer.stop_rasterizing()
     2606 
  -&gt; 2607         mimage._draw_list_compositing_images(renderer, self, artists)
     2608 
     2609         renderer.close_group('axes')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in draw(self, renderer)
      809                 if markevery is not None:
      810                     subsampled = _mark_every_path(markevery, tpath,
  --&gt; 811                                                   affine, self.axes.transAxes)
      812                 else:
      813                     subsampled = tpath
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      220             raise ValueError('`markevery` is iterable but '
      221                 'not a valid form of numpy fancy indexing; '
  --&gt; 222                 'markevery=%s' % (markevery,))
      223     else:
      224         raise ValueError('Value of `markevery` is not '
  
  ValueError: `markevery` is iterable but not a valid form of numpy fancy indexing; markevery=[1, 5, 9]
  </code></pre>
  <p>if I set markevery = to_mark, I get</p>
  <pre><code>IndexError                                Traceback (most recent call last)
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      215         try:
  --&gt; 216             return Path(verts[markevery],
      217                     _slice_or_none(codes, markevery))
  
  IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 10
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-319-ce96ba06eb23&gt; in &lt;module&gt;()
       65 
       66         #plt.plot()
  ---&gt; 67         plt.savefig(file_path)
       68         #with open(file_path, 'wb') as f:
       69             #plt.savefig(file_path)
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\pyplot.py in savefig(*args, **kwargs)
      708 def savefig(*args, **kwargs):
      709     fig = gcf()
  --&gt; 710     res = fig.savefig(*args, **kwargs)
      711     fig.canvas.draw_idle()   # need this if 'transparent=True' to reset colors
      712     return res
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\figure.py in savefig(self, fname, **kwargs)
     2033             self.set_frameon(frameon)
     2034 
  -&gt; 2035         self.canvas.print_figure(fname, **kwargs)
     2036 
     2037         if frameon:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
     2261                 orientation=orientation,
     2262                 bbox_inches_restore=_bbox_inches_restore,
  -&gt; 2263                 **kwargs)
     2264         finally:
     2265             if bbox_inches and restore_bbox:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_pdf.py in print_pdf(self, filename, **kwargs)
     2584                 RendererPdf(file, image_dpi, height, width),
     2585                 bbox_inches_restore=_bbox_inches_restore)
  -&gt; 2586             self.figure.draw(renderer)
     2587             renderer.finalize()
     2588             if not isinstance(filename, PdfPages):
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\figure.py in draw(self, renderer)
     1473 
     1474             mimage._draw_list_compositing_images(
  -&gt; 1475                 renderer, self, artists, self.suppressComposite)
     1476 
     1477             renderer.close_group('figure')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
     2605             renderer.stop_rasterizing()
     2606 
  -&gt; 2607         mimage._draw_list_compositing_images(renderer, self, artists)
     2608 
     2609         renderer.close_group('axes')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in draw(self, renderer)
      809                 if markevery is not None:
      810                     subsampled = _mark_every_path(markevery, tpath,
  --&gt; 811                                                   affine, self.axes.transAxes)
      812                 else:
      813                     subsampled = tpath
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      220             raise ValueError('`markevery` is iterable but '
      221                 'not a valid form of numpy fancy indexing; '
  --&gt; 222                 'markevery=%s' % (markevery,))
      223     else:
      224         raise ValueError('Value of `markevery` is not '
  
  ValueError: `markevery` is iterable but not a valid form of numpy fancy indexing; markevery=[False, True, False, False, False, True, False, False, False, True]
  
  ---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      215         try:
  --&gt; 216             return Path(verts[markevery],
      217                     _slice_or_none(codes, markevery))
  
  IndexError: boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 10
  
  During handling of the above exception, another exception occurred:
  
  ValueError                                Traceback (most recent call last)
  ~\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
      330                 pass
      331             else:
  --&gt; 332                 return printer(obj)
      333             # Finally look for special method names
      334             method = get_real_method(obj, self.print_method)
  
  ~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in &lt;lambda&gt;(fig)
      235 
      236     if 'png' in formats:
  --&gt; 237         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
      238     if 'retina' in formats or 'png2x' in formats:
      239         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
  
  ~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
      119 
      120     bytes_io = BytesIO()
  --&gt; 121     fig.canvas.print_figure(bytes_io, **kw)
      122     data = bytes_io.getvalue()
      123     if fmt == 'svg':
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
     2210                     orientation=orientation,
     2211                     dryrun=True,
  -&gt; 2212                     **kwargs)
     2213                 renderer = self.figure._cachedRenderer
     2214                 bbox_inches = self.figure.get_tightbbox(renderer)
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
      511 
      512     def print_png(self, filename_or_obj, *args, **kwargs):
  --&gt; 513         FigureCanvasAgg.draw(self)
      514         renderer = self.get_renderer()
      515         original_dpi = renderer.dpi
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\backends\backend_agg.py in draw(self)
      431             # if toolbar:
      432             #     toolbar.set_cursor(cursors.WAIT)
  --&gt; 433             self.figure.draw(self.renderer)
      434             # A GUI class may be need to update a window using this draw, so
      435             # don't forget to call the superclass.
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\figure.py in draw(self, renderer)
     1473 
     1474             mimage._draw_list_compositing_images(
  -&gt; 1475                 renderer, self, artists, self.suppressComposite)
     1476 
     1477             renderer.close_group('figure')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
     2605             renderer.stop_rasterizing()
     2606 
  -&gt; 2607         mimage._draw_list_compositing_images(renderer, self, artists)
     2608 
     2609         renderer.close_group('axes')
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
      139     if not_composite or not has_images:
      140         for a in artists:
  --&gt; 141             a.draw(renderer)
      142     else:
      143         # Composite any adjacent images together
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
       53                 renderer.start_filter()
       54 
  ---&gt; 55             return draw(artist, renderer, *args, **kwargs)
       56         finally:
       57             if artist.get_agg_filter() is not None:
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in draw(self, renderer)
      809                 if markevery is not None:
      810                     subsampled = _mark_every_path(markevery, tpath,
  --&gt; 811                                                   affine, self.axes.transAxes)
      812                 else:
      813                     subsampled = tpath
  
  ~\AppData\Roaming\Python\Python36\site-packages\matplotlib\lines.py in _mark_every_path(markevery, tpath, affine, ax_transform)
      220             raise ValueError('`markevery` is iterable but '
      221                 'not a valid form of numpy fancy indexing; '
  --&gt; 222                 'markevery=%s' % (markevery,))
      223     else:
      224         raise ValueError('Value of `markevery` is not '
  
  ValueError: `markevery` is iterable but not a valid form of numpy fancy indexing; markevery=[False, True, False, False, False, True, False, False, False, True]
  </code></pre>
  <p>I'd be very thankful for any input!</p>