# PyGMT - psmeca option

**URL:** <https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692>\
**Category:** PyGMT Q&A\
**Tags:** gmt\
**Created:** [July 19, 2020, 8:41pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692 "2020-07-19T20:41:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgjholt](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sgjholt](https://forum.generic-mapping-tools.org/u/sgjholt)\
**Post date:** [July 19, 2020, 8:41pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692/1 "2020-07-19T20:41:25Z")

</div>

Hi all,

I searched through the source code on GitHub (master) and it looks the team has not yet got around to implementing a method for [psmeca](https://docs.generic-mapping-tools.org/latest/supplements/seis/psmeca.html?highlight=psmeca) in base\_plotting.py. Am I correct? Or is there another way to draw earthquake focal mechanisms using PyGMT?

If not, it looks like I could try to implement it myself following the examples you have calling other modules (e.g. coast).

Cheers,  
James

UPDATE:

Looks like I was right, you guys did a really great job of making the code easily modular. I was able to (at least partially) implement the meca feature. I did this quickly and committed this back to my [forked version](https://github.com/sgjholt/pygmt/tree/master/pygmt) of the master branch. Have not submitted a pull request because it probably violates your contributers code of conduct - haven’t had the time to review it thoroughly yet.

Code example:

> fig = pygmt.Figure()  
> fig.basemap(region=region, frame=“af”, projection=“M0/0/8i”)  
> fig.coast(shorelines=True, N=2, land=‘gray’, water=‘skyblue’)  
> fig.meca(table=“MTTable.txt”, Sd=“1”, C=" ")  
> fig.show()

 ![Screen Shot 2020-07-19 at 7.17.27 PM](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/dde7b7f75ebc2df92eed4eff3e6bb8c6554d54b2.jpeg)

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [July 20, 2020, 2:30am UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692/2 "2020-07-20T02:30:49Z")

</div>

@sgjholt Actually there is already a PR for it (see [https://github.com/GenericMappingTools/pygmt/pull/516](https://github.com/GenericMappingTools/pygmt/pull/516)). Feel free to try it and give your feedbacks.

---

<div class="post-metadata">

**Author:** ![sgjholt](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@sgjholt](https://forum.generic-mapping-tools.org/u/sgjholt)\
**Post date:** [July 20, 2020, 2:53pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692/3 "2020-07-20T14:53:48Z")

</div>

@seisman Darn, I should have double checked the PRs. Oh well, I still learned a lot about the project doing it and it didn’t take long. I will give this branch a try. Thanks for responding!

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [August 10, 2020, 4:01am UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692/4 "2020-08-10T04:01:39Z")

</div>

FYI [https://github.com/GenericMappingTools/pygmt/pull/516](https://github.com/GenericMappingTools/pygmt/pull/516) has been merged into PyGMT (thanks to [@tjnewton](https://github.com/tjnewton) and @liamtoney), and should be available for the next v0.2.0 release.

Alternatively, you can install from the PyGMT master branch directly from Github using `pip install https://github.com/GenericMappingTools/pygmt/archive/master.zip` and start using it now. Fair warning that there might be some bugs/issues, but it would be good to have someone test it and report back on how we can improve [`meca`](https://www.pygmt.org/dev/api/generated/pygmt.Figure.meca.html#pygmt.Figure.meca).

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [September 12, 2020, 9:21pm UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692/5 "2020-09-12T21:21:20Z")

</div>

PyGMT v0.2.0 has just been released (see [PyGMT v0.2.0 released](https://flint.soest.hawaii.edu/t/pygmt-v0-2-0-released/879)), and this comes with the [`meca`](https://www.pygmt.org/v0.2.0/api/generated/pygmt.Figure.meca.html) function. Do you want to give it a try if you have time?

From memory, it seems like text annotations might be the only thing that doesn’t work yet, but we could get that into v0.2.1 perhaps. Would be good to see if there’s any other rough edges that needs to be improved.

---

<div class="post-metadata">

**Author:** ![Adnan](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Adnan](https://forum.generic-mapping-tools.org/u/Adnan)\
**Post date:** [June 17, 2023, 6:20am UTC](https://forum.generic-mapping-tools.org/t/pygmt-psmeca-option/692/6 "2023-06-17T06:20:11Z")

</div>

May you share your text file. I am struggle with similar issue but still no solution.
