# Buggy code
def _scalar_plotting_units(scalar_value, plotting_units):
    """Handle conversion to plotting units for barbs and arrows."""
    if plotting_units:
        if hasattr(scalar_value, "units"):
            scalar_value = scalar_value.to(plotting_units)
        else:
            raise ValueError(
                "To convert to plotting units, units must be attached to "
                "scalar value being converted."
            )
    return scalar_value


# Traceback (ValueError)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-df2b7c9f2f48> in <module>
25 pc.panels = [panel]
26
---> 27 pc.show()

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/declarative.py in show(self)
566     def show(self):
567         """Show the constructed graphic on the screen."""
--> 568         self.draw()
569         plt.show()
570

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/declarative.py in draw(self)
553         for panel in self.panels:
554             with panel.hold_trait_notifications():
--> 555                 panel.draw()
556
557     def save(self, *args, **kwargs):

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/declarative.py in draw(self)
744             for p in self.plots:
745                 with p.hold_trait_notifications():
--> 746                     p.draw()
747
748             # Add all of the maps

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/declarative.py in draw(self)
1532         if self._need_redraw:
1533             if getattr(self, 'handle', None) is None:
-> 1534                 self._build()
1535             self._need_redraw = False
1536

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/declarative.py in _build(self)
1592                     else:
1593                         self.handle.plot_parameter(location, data[ob_type][subset],
-> 1594                                                    **field_kwargs)
1595             else:
1596                 field_kwargs.pop('formatter')

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/station_plot.py in plot_parameter(self, location, parameter, formatter, **kwargs)
199         # If plot_units specified, convert the data to those units
200         plotting_units = kwargs.pop('plot_units', None)
--> 201         parameter = self._scalar_plotting_units(parameter, plotting_units)
202         if hasattr(parameter, 'units'):
203             parameter = parameter.magnitude

~/miniconda3/envs/new_main/lib/python3.7/site-packages/metpy/plots/station_plot.py in _scalar_plotting_units(scalar_value, plotting_units)
349                 scalar_value = scalar_value.to(plotting_units)
350             else:
--> 351                 raise ValueError('To convert to plotting units, units must be attached to '
352                                  'scalar value being converted.')
353         return scalar_value

ValueError: To convert to plotting units, units must be attached to scalar value being converted.
/Users/kgoebber/miniconda3/envs/new_main/lib/python3.7/site-packages/cartopy/mpl/geoaxes.py:388: MatplotlibDeprecationWarning:
The 'inframe' parameter of draw() was deprecated in Matplotlib 3.3 and will be removed two minor releases later. Use Axes.redraw_in_frame() instead. If any parameter follows 'inframe', they should be passed as keyword, not positionally.
inframe=inframe)

# Fixed code
def _scalar_plotting_units(scalar_value, plotting_units):
    """Handle conversion to plotting units for non-vector quantities."""
    if plotting_units:
        if hasattr(scalar_value, "units"):
            scalar_value = scalar_value.to(plotting_units)
        else:
            raise ValueError(
                "To convert to plotting units, units must be attached to "
                "scalar value being converted."
            )
    return scalar_value