# CPT file conversion

**URL:** <https://forum.generic-mapping-tools.org/t/cpt-file-conversion/862>\
**Category:** Q&A\
**Created:** [September 7, 2020, 11:06pm UTC](https://forum.generic-mapping-tools.org/t/cpt-file-conversion/862 "2020-09-07T23:06:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dietmar](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/dietmar/32/286_2.png) [@dietmar](https://forum.generic-mapping-tools.org/u/dietmar)\
**Post date:** [September 7, 2020, 11:06pm UTC](https://forum.generic-mapping-tools.org/t/cpt-file-conversion/862/1 "2020-09-07T23:06:46Z")

</div>

Is there a recipe for converting a GMT cpt file for use in matplotlib/cartopy?

---

<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 8, 2020, 1:51am UTC](https://forum.generic-mapping-tools.org/t/cpt-file-conversion/862/2 "2020-09-08T01:51:23Z")

</div>

Not that I know of, but someone did write some code to do the opposite (matplotlib to gmt) before, you can find it at [https://github.com/mjziebarth/gmt-python-extensions/blob/master/gmt\_extensions/colormap.py](https://github.com/mjziebarth/gmt-python-extensions/blob/master/gmt_extensions/colormap.py).

Is there a particular colormap you’d like to convert? One of the [Scientific Colour Maps](http://www.fabiocrameri.ch/colourmaps.php) perhaps or another one?

---

<div class="post-metadata">

**Author:** ![dietmar](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/dietmar/32/286_2.png) [@dietmar](https://forum.generic-mapping-tools.org/u/dietmar)\
**Post date:** [September 8, 2020, 2:14am UTC](https://forum.generic-mapping-tools.org/t/cpt-file-conversion/862/3 "2020-09-08T02:14:37Z")

</div>

Thanks for the link. It’s about a custom-made colour map.

---

<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:** [June 7, 2022, 1:20am UTC](https://forum.generic-mapping-tools.org/t/cpt-file-conversion/862/4 "2022-06-07T01:20:10Z")

</div>

This repository may provide functions you need:

> **[GitHub - shaharkadmiel/cmaptools: A convenient package to read GMT style cpt-files...](https://github.com/shaharkadmiel/cmaptools)**
>
> A convenient package to read GMT style cpt-files to matplotlib cmaps and mimic the dynamic scaling around a hinge point
