# Create custom colormap?

**URL:** <https://forum.generic-mapping-tools.org/t/create-custom-colormap/3190>\
**Category:** PyGMT Q&A\
**Created:** [August 4, 2022, 8:27pm UTC](https://forum.generic-mapping-tools.org/t/create-custom-colormap/3190 "2022-08-04T20:27:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ijbrewster](https://avatars.discourse-cdn.com/v4/letter/i/ce7236/32.png) [@ijbrewster](https://forum.generic-mapping-tools.org/u/ijbrewster)\
**Post date:** [August 4, 2022, 8:27pm UTC](https://forum.generic-mapping-tools.org/t/create-custom-colormap/3190/1 "2022-08-04T20:27:30Z")

</div>

In some matplotlib code I have, I have created a custom colormap using the matplotlib `LinearSegmentedColormap` and a list of red, green, blue, alpha values at various stops between 0 and 1. I would now like to use this same colormap in pygmt, but all I have been able to find so far is the `pygmt.makecpt` function which from what I can tell only allows you to modify one of the standard colormaps, not create a new custom one.

As such, is there a way to either a) convert the matplotlib colormap into one that will work with pygmt, or b) create from scratch a new colormap for pygmt using the colors/stops I have?

Thanks.

---

<div class="post-metadata">

**Author:** ![ManonDls](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/manondls/32/2441_2.png) [@ManonDls](https://forum.generic-mapping-tools.org/u/ManonDls)\
**Post date:** [August 5, 2022, 9:46am UTC](https://forum.generic-mapping-tools.org/t/create-custom-colormap/3190/2 "2022-08-05T09:46:31Z")

</div>

In GMT you can work from saved .cpt files directly. Such text file contains a list of colour gradients, defined as two bounding RGB colours and a range of values (e.g. [http://soliton.vm.bytemark.co.uk/pub/cpt-city/views/totp-cpt.html](http://soliton.vm.bytemark.co.uk/pub/cpt-city/views/totp-cpt.html)). You can use the file directly or adapt the value range to your data with makecpt.
