toolsforexperiments / plottr

A flexible plotting and data analysis tool.
https://github.com/toolsforexperiments/plottr
MIT License
46 stars 56 forks source link

Plottr and doNd(.. do_plot=True) error #179

Closed MdKquantum closed 3 years ago

MdKquantum commented 3 years ago

While trying to use plottr as a tool to monitor to live plot my data and my notebook as a logbook of the measurements I encountered the following bug/error. When plottr is running, a doNd qcodes function with do_plot = True, throws an error before the plot is displayed in the notebook. I've pasted the exact error message at the end of this post.

I'm currently on Plottr 0.6.0 and Qcodes 0.24.0. Is this a known issue with a fix or a unwanted bug?

Thank you for your help

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-10-ea1943b0e091> in <module>
----> 1 do1d(Vsd,0.5,0,10,0.2,Is,do_plot=True)

~\Anaconda3\envs\qcmos\lib\site-packages\qcodes\utils\dataset\doNd.py in do1d(param_set, start, stop, num_points, delay, enter_actions, exit_actions, write_period, measurement_name, exp, do_plot, use_threads, additional_setpoints, show_progress, *param_meas)
    336             )
    337         dataset = datasaver.dataset
--> 338     return _handle_plotting(dataset, do_plot, interrupted())
    339 
    340 

~\Anaconda3\envs\qcmos\lib\site-packages\qcodes\utils\dataset\doNd.py in _handle_plotting(data, do_plot, interrupted)
    498     """
    499     if do_plot:
--> 500         res = plot(data)
    501     else:
    502         res = data, [None], [None]

~\Anaconda3\envs\qcmos\lib\site-packages\qcodes\utils\dataset\doNd.py in plot(data, save_pdf, save_png)
    538         if save_pdf:
    539             full_path = os.path.join(pdf_dif, f'{dataid}_{i}.pdf')
--> 540             ax.figure.savefig(full_path, dpi=500)
    541         if save_png:
    542             full_path = os.path.join(png_dir, f'{dataid}_{i}.png')

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\figure.py in savefig(self, fname, transparent, **kwargs)
   2309                 patch.set_edgecolor('none')
   2310 
-> 2311         self.canvas.print_figure(fname, **kwargs)
   2312 
   2313         if transparent:

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2215                     orientation=orientation,
   2216                     bbox_inches_restore=_bbox_inches_restore,
-> 2217                     **kwargs)
   2218             finally:
   2219                 if bbox_inches and restore_bbox:

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\backend_bases.py in wrapper(*args, **kwargs)
   1637             kwargs.pop(arg)
   1638 
-> 1639         return func(*args, **kwargs)
   1640 
   1641     return wrapper

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\backends\backend_pdf.py in print_pdf(self, filename, dpi, bbox_inches_restore, metadata)
   2591                 RendererPdf(file, dpi, height, width),
   2592                 bbox_inches_restore=bbox_inches_restore)
-> 2593             self.figure.draw(renderer)
   2594             renderer.finalize()
   2595             if not isinstance(filename, PdfPages):

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\figure.py in draw(self, renderer)
   1862             self.patch.draw(renderer)
   1863             mimage._draw_list_compositing_images(
-> 1864                 renderer, self, artists, self.suppressComposite)
   1865 
   1866             renderer.close_group('figure')

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    129     if not_composite or not has_images:
    130         for a in artists:
--> 131             a.draw(renderer)
    132     else:
    133         # Composite any adjacent images together

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     39                 renderer.start_filter()
     40 
---> 41             return draw(artist, renderer, *args, **kwargs)
     42         finally:
     43             if artist.get_agg_filter() is not None:

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*inner_args, **inner_kwargs)
    409                          else deprecation_addendum,
    410                 **kwargs)
--> 411         return func(*inner_args, **inner_kwargs)
    412 
    413     return wrapper

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe)
   2705                 artists.remove(spine)
   2706 
-> 2707         self._update_title_position(renderer)
   2708 
   2709         if not self.axison or inframe:

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\axes\_base.py in _update_title_position(self, renderer)
   2646                 _log.debug('top of axes not in the figure, so title not moved')
   2647                 return
-> 2648             if title.get_window_extent(renderer).ymin < top:
   2649                 _, y = self.transAxes.inverted().transform((0, top))
   2650                 title.set_position((x, y))

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\text.py in get_window_extent(self, renderer, dpi)
    900 
    901         with cbook._setattr_cm(self.figure, dpi=dpi):
--> 902             bbox, info, descent = self._get_layout(self._renderer)
    903             x, y = self.get_unitless_position()
    904             x, y = self.get_transform().transform((x, y))

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\text.py in _get_layout(self, renderer)
    294             if clean_line:
    295                 w, h, d = renderer.get_text_width_height_descent(
--> 296                     clean_line, self._fontproperties, ismath=ismath)
    297             else:
    298                 w = h = d = 0

~\Anaconda3\envs\qcmos\lib\site-packages\matplotlib\backends\_backend_pdf_ps.py in get_text_width_height_descent(self, s, prop, ismath)
    100         else:
    101             font = self._get_font_ttf(prop)
--> 102             font.set_text(s, 0.0, flags=ft2font.LOAD_NO_HINTING)
    103             w, h = font.get_width_height()
    104             d = font.get_descent()

RuntimeError: In set_text: Could not load glyph (error code 0x14)
jenshnielsen commented 3 years ago

How are you launching plottr? This seems like a multi threading issue but plottr and qcodes dond loop should never run in the same process unless you are doing something unusual?

jenshnielsen commented 3 years ago

@MdKquantum did you resolve this?

MdKquantum commented 3 years ago

I think It was an issue with sharing threads as you suggested, at the moment of reporting I was running plottr and qcodes from the same notebook. Besides that I had once seen a similar error while running plottr from spyder while qcodes was in jupyter but I cannot reproduce that behaviour anymore.

jenshnielsen commented 3 years ago

ok thanks, I would recommend lauching plottr from the command line using the scripts that plottr installs (plottr-inspectr etc)