simpeg-research / earthscope-mt-course

Tutorial Notebooks for an MT workflow
MIT License
15 stars 3 forks source link

Error on mtpy #4

Open sgkang opened 1 month ago

sgkang commented 1 month ago

Getting a following error when running tf.plot_mt_response(): @kujaku11

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/anaconda3/envs/em/lib/python3.11/site-packages/ipywidgets/widgets/interaction.py:240, in interactive.update(self, *args)
    238     value = widget.get_interact_value()
    239     self.kwargs[widget._kwarg] = value
--> 240 self.result = self.f(**self.kwargs)
    241 show_inline_matplotlib_plots()
    242 if self.auto_display and self.result is not None:

Cell In[3], line 9, in foo(name, component)
      7 def foo(name, component):
      8     tf = mc.get_tf(name)
----> 9     tf.plot_mt_response()

File ~/Project/mtpy-v2/mtpy/core/mt.py:542, in MT.plot_mt_response(self, **kwargs)
    529 def plot_mt_response(self, **kwargs):
    530     """
    531     Returns a mtpy.imaging.plotresponse.PlotResponse object
    532 
   (...)
    539 
    540     """
--> 542     plot_obj = PlotMTResponse(
    543         z_object=self.Z,
    544         t_object=self.Tipper,
    545         pt_obj=self.pt,
    546         station=self.station,
    547         **kwargs,
    548     )
    550     return plot_obj

File ~/Project/mtpy-v2/mtpy/imaging/plot_mt_response.py:117, in PlotMTResponse.__init__(self, z_object, t_object, pt_obj, station, **kwargs)
    115 # plot on initializing
    116 if self.show_plot:
--> 117     self.plot()

File ~/Project/mtpy-v2/mtpy/imaging/plot_mt_response.py:614, in PlotMTResponse.plot(self)
    612 if self.plot_title is None:
    613     self.plot_title = self.station
--> 614 self.fig.suptitle(self.plot_title, fontdict=self.font_dict)
    616 # be sure to show
    617 if self.show_plot:

File ~/anaconda3/envs/em/lib/python3.11/site-packages/matplotlib/figure.py:328, in FigureBase.suptitle(self, t, **kwargs)
    320 @_docstring.Substitution(x0=0.5, y0=0.98, name='suptitle', ha='center',
    321                          va='top', rc='title')
    322 @_docstring.copy(_suplabels)
    323 def suptitle(self, t, **kwargs):
    324     # docstring from _suplabels...
    325     info = {'name': '_suptitle', 'x0': 0.5, 'y0': 0.98,
    326             'ha': 'center', 'va': 'top', 'rotation': 0,
    327             'size': 'figure.titlesize', 'weight': 'figure.titleweight'}
--> 328     return self._suplabels(t, info, **kwargs)

File ~/anaconda3/envs/em/lib/python3.11/site-packages/matplotlib/figure.py:314, in FigureBase._suplabels(self, t, info, **kwargs)
    312     suplab.set(**kwargs)
    313 else:
--> 314     suplab = self.text(x, y, t, **kwargs)
    315     setattr(self, info['name'], suplab)
    316 suplab._autopos = autopos

File ~/anaconda3/envs/em/lib/python3.11/site-packages/matplotlib/figure.py:1126, in FigureBase.text(self, x, y, s, fontdict, **kwargs)
   1087 """
   1088 Add text to figure.
   1089 
   (...)
   1119 .pyplot.text
   1120 """
   1121 effective_kwargs = {
   1122     'transform': self.transSubfigure,
   1123     **(fontdict if fontdict is not None else {}),
   1124     **kwargs,
   1125 }
-> 1126 text = Text(x=x, y=y, text=s, **effective_kwargs)
   1127 text.set_figure(self)
   1128 text.stale_callback = _stale_figure_callback

File ~/anaconda3/envs/em/lib/python3.11/site-packages/matplotlib/text.py:155, in Text.__init__(self, x, y, text, color, verticalalignment, horizontalalignment, multialignment, fontproperties, rotation, linespacing, rotation_mode, usetex, wrap, transform_rotates_text, parse_math, antialiased, **kwargs)
    138 self._text = ''
    139 self._reset_visual_defaults(
    140     text=text,
    141     color=color,
   (...)
    153     antialiased=antialiased
    154 )
--> 155 self.update(kwargs)

File ~/anaconda3/envs/em/lib/python3.11/site-packages/matplotlib/text.py:197, in Text.update(self, kwargs)
    194 def update(self, kwargs):
    195     # docstring inherited
    196     ret = []
--> 197     kwargs = cbook.normalize_kwargs(kwargs, Text)
    198     sentinel = object()  # bbox can be None, so use another sentinel.
    199     # Update fontproperties first, as it has lowest priority.

File ~/anaconda3/envs/em/lib/python3.11/site-packages/matplotlib/cbook.py:1843, in normalize_kwargs(kw, alias_mapping)
   1841 canonical = to_canonical.get(k, k)
   1842 if canonical in canonical_to_seen:
-> 1843     raise TypeError(f"Got both {canonical_to_seen[canonical]!r} and "
   1844                     f"{k!r}, which are aliases of one another")
   1845 canonical_to_seen[canonical] = k
   1846 ret[canonical] = v

TypeError: Got both 'size' and 'fontsize', which are aliases of one another
kujaku11 commented 1 month ago

@sgkang Right, this is a matplotlib issue. I fixed the issue in the "mtpy-v2/simpeg" branch. See if the fixes it.