# AttributeError after running Source code from "Tutorial » Merging Seismograms"

**URL:** <https://discourse.obspy.org/t/attributeerror-after-running-source-code-from-tutorial-merging-seismograms/1392>\
**Category:** Usage Questions\
**Created:** [March 31, 2022, 4:17am UTC](https://discourse.obspy.org/t/attributeerror-after-running-source-code-from-tutorial-merging-seismograms/1392 "2022-03-31T04:17:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frostforestcdjl](https://discourse.obspy.org/user_avatar/discourse.obspy.org/frostforestcdjl/32/516_2.png) [@frostforestcdjl](https://discourse.obspy.org/u/frostforestcdjl)\
**Post date:** [March 31, 2022, 4:17am UTC](https://discourse.obspy.org/t/attributeerror-after-running-source-code-from-tutorial-merging-seismograms/1392/1 "2022-03-31T04:17:19Z")

</div>

I downloaded the Source code ([https://docs.obspy.org/tutorial/code\_snippets/merging\_seismograms.py](https://docs.obspy.org/tutorial/code_snippets/merging_seismograms.py))

from the page of “Tutorial » Merging Seismograms” ([Merging Seismograms — ObsPy 1.4.2 documentation](https://docs.obspy.org/tutorial/code_snippets/merging_seismograms.html))

and ran it in my terminal and my jupyter notebook independently.

A). Run in my terminal: a message as “merging\_seismograms.py:28: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.”

B). Run in my Jupyter notebook: error message shows at beginning is:  
AttributeError Traceback (most recent call last)  
Input In [1], in \<cell line: 21\>()  
19 plt.subplot(4, 1, 4, sharex=ax)  
20 plt.plot(st[0].times(), st[0].data, ‘r’)  
—\> 21 plt.show()

and the error message shows in the end is:  
AttributeError: ‘NoneType’ object has no attribute ‘canvas’

* * *

I installed pyqt5 or replaced plt.show() with plt.savefig(‘filename.png’), but they didn’t help.

My question is: should I install something else to solve this problem? or should I change the code somewhere to solve the issue?

Any possible way to solve the problem is appreciated.  
Thanks!

---

<div class="post-metadata">

**Author:** ![trichter](https://discourse.obspy.org/user_avatar/discourse.obspy.org/trichter/32/226_2.png) [@trichter](https://discourse.obspy.org/u/trichter)\
**Post date:** [April 4, 2022, 12:45pm UTC](https://discourse.obspy.org/t/attributeerror-after-running-source-code-from-tutorial-merging-seismograms/1392/2 "2022-04-04T12:45:40Z")

</div>

Hi!

Apparently this code snippet of the tutorial does not work with new matplotlib versions. I think if you delete lines 2 and 3 of the code it should work.

---

<div class="post-metadata">

**Author:** ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)\
**Post date:** [April 5, 2022, 2:05pm UTC](https://discourse.obspy.org/t/attributeerror-after-running-source-code-from-tutorial-merging-seismograms/1392/3 "2022-04-05T14:05:12Z")

</div>

see [docs: Fix merge seismograms and update seismometer correction tutorial (and maybe some more smaller things) by megies · Pull Request #3036 · obspy/obspy · GitHub](https://github.com/obspy/obspy/pull/3036) which updates the example code snippet

---

<div class="post-metadata">

**Author:** ![frostforestcdjl](https://discourse.obspy.org/user_avatar/discourse.obspy.org/frostforestcdjl/32/516_2.png) [@frostforestcdjl](https://discourse.obspy.org/u/frostforestcdjl)\
**Post date:** [July 25, 2022, 5:01am UTC](https://discourse.obspy.org/t/attributeerror-after-running-source-code-from-tutorial-merging-seismograms/1392/4 "2022-07-25T05:01:03Z")

</div>

Thanks for your help!
