|
From: Lionel R. <lro...@li...> - 2006-07-07 07:11:33
|
Hi all, Is it possible to import colormap file from GMT (.cpt) to basemap? If yes how can we do that? Thanks -- Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
|
From: <dd...@ja...> - 2006-07-07 08:12:17
Attachments:
sample.png
|
On Friday 07 July 2006 4:11 pm, Lionel Roubeyrie wrote: > Hi all, > Is it possible to import colormap file from GMT (.cpt) to basemap? > If yes how can we do that? > Thanks It's possible. Here's how I've been doing it. (1) I use the gmtcolormapPylab function defined in: http://sourceforge.net/mailarchive/message.php?msg_id=11255878 (2) Using the above function and a GMT cpt file (e.g. GMT_no_green.cpt), I set a color dictionary as: cdict = gmtcolormapPylab("GMT_no_green") (3) I define a colormap using: mycmap = cm.colors.LinearSegmentedColormap("GMT_no_green",cdict,256) (4) I apply the above using cmap=mycolormap in contourf or pcolormesh. By the way, in case you don't know of the following site, it has an exhaustive selection of color palettes: http://cpt-city.org.uk/ I've also attached an example of a basemap image using a cpt from the above site. Masked values not defined by the colormap are shown in gray. |
|
From: Lionel R. <lro...@li...> - 2006-07-07 09:05:49
|
Work very fine here, thanks for the links. Le Vendredi 07 Juillet 2006 10:11, dd...@ja... a =C3=A9crit=C2=A0: > On Friday 07 July 2006 4:11 pm, Lionel Roubeyrie wrote: > > Hi all, > > Is it possible to import colormap file from GMT (.cpt) to basemap? > > If yes how can we do that? > > Thanks > > It's possible. Here's how I've been doing it. > > (1) I use the gmtcolormapPylab function defined in: > http://sourceforge.net/mailarchive/message.php?msg_id=3D11255878 > > (2) Using the above function and a GMT cpt file (e.g. > GMT_no_green.cpt), I set a color dictionary as: > cdict =3D gmtcolormapPylab("GMT_no_green") > > (3) I define a colormap using: > mycmap =3D cm.colors.LinearSegmentedColormap("GMT_no_green",cdict,256) > > (4) I apply the above using cmap=3Dmycolormap in contourf or pcolormesh. > > By the way, in case you don't know of the following site, it has an > exhaustive selection of color palettes: http://cpt-city.org.uk/ > > I've also attached an example of a basemap image using a cpt from the > above site. Masked values not defined by the colormap are shown in > gray. =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
|
From: Lionel R. <lro...@li...> - 2006-07-18 09:25:48
|
HI, how do you set the arrows on the bottom and the top of your colorbar? I don= 't=20 find any option for that? Thanks Le Vendredi 07 Juillet 2006 10:11, dd...@ja... a =C3=A9crit=C2=A0: > On Friday 07 July 2006 4:11 pm, Lionel Roubeyrie wrote: > > Hi all, > > Is it possible to import colormap file from GMT (.cpt) to basemap? > > If yes how can we do that? > > Thanks > > It's possible. Here's how I've been doing it. > > (1) I use the gmtcolormapPylab function defined in: > http://sourceforge.net/mailarchive/message.php?msg_id=3D11255878 > > (2) Using the above function and a GMT cpt file (e.g. > GMT_no_green.cpt), I set a color dictionary as: > cdict =3D gmtcolormapPylab("GMT_no_green") > > (3) I define a colormap using: > mycmap =3D cm.colors.LinearSegmentedColormap("GMT_no_green",cdict,256) > > (4) I apply the above using cmap=3Dmycolormap in contourf or pcolormesh. > > By the way, in case you don't know of the following site, it has an > exhaustive selection of color palettes: http://cpt-city.org.uk/ > > I've also attached an example of a basemap image using a cpt from the > above site. Masked values not defined by the colormap are shown in > gray. =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
|
From: Jeff W. <js...@fa...> - 2006-07-07 11:53:17
Attachments:
gmt_cm.py
|
Lionel Roubeyrie wrote: > Hi all, > Is it possible to import colormap file from GMT (.cpt) to basemap? If yes how > can we do that? > Thanks > Lionel: I had included the GMT colormaps in matplotlib, but had to take them out because of licensing issues. If you want to put them back in, put the attached file in your matplotlib install directory <sys.prefix>/lib/python2.4/site-packages/matplotlib. Then use a text editor to add the following lines to _cm.py (in the same directory) from gmt_cm import addcmaps addcmaps(datad) right above the line # reverse all the colormaps. This will give you the colormaps GMT_gebco GMT_globe GMT_haxby GMT_no_green GMT_ocean GMT_polar GMT_red2green GMT_relief GMT_seis GMT_wysiwyg and the corresponding reversed colormaps (with '_r' appended to the name). -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449 325 Broadway Boulder, CO, USA 80305-3328 |
|
From: Lionel R. <lro...@li...> - 2006-07-07 13:14:39
|
Hi Jeff, thanks for the hint, I just need to import one personal GMT file maked a ti= me=20 ago and used in a plotting project based on GMT, which I try to convert to= =20 matplotlib. Now I have a little problem to plot a basemap with subplots. Trying to use= =20 contour_demo.py mixed with hist.py to have a map with contours and under it= =20 an histogram of values, I can't set the colorbar else I loose the map. I=20 think I have a problem with axes but I'm not very familar with subplotting. Have you an idea of how can I do that? Le Vendredi 07 Juillet 2006 13:53, Jeff Whitaker a =C3=A9crit=C2=A0: > Lionel Roubeyrie wrote: > > Hi all, > > Is it possible to import colormap file from GMT (.cpt) to basemap? If y= es > > how can we do that? > > Thanks > > Lionel: I had included the GMT colormaps in matplotlib, but had to take > them out because of licensing issues. If you want to put them back in, > put the attached file in your matplotlib install directory > <sys.prefix>/lib/python2.4/site-packages/matplotlib. Then use a text > editor to add the following lines to _cm.py (in the same directory) > > from gmt_cm import addcmaps > addcmaps(datad) > > right above the line > > # reverse all the colormaps. > > This will give you the colormaps > > GMT_gebco > GMT_globe > GMT_haxby > GMT_no_green > GMT_ocean > GMT_polar > GMT_red2green > GMT_relief > GMT_seis > GMT_wysiwyg > > and the corresponding reversed colormaps (with '_r' appended to the name). > > > -Jeff =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
|
From: Lionel R. <lro...@li...> - 2006-07-07 13:52:16
|
Arg, sorry, I have found the response by myself, I just have to use=20 figure.add_subplot to fix it. Le Vendredi 07 Juillet 2006 15:14, Lionel Roubeyrie a =C3=A9crit=C2=A0: > Hi Jeff, > thanks for the hint, I just need to import one personal GMT file maked a > time ago and used in a plotting project based on GMT, which I try to > convert to matplotlib. > Now I have a little problem to plot a basemap with subplots. Trying to use > contour_demo.py mixed with hist.py to have a map with contours and under = it > an histogram of values, I can't set the colorbar else I loose the map. I > think I have a problem with axes but I'm not very familar with subplottin= g. > Have you an idea of how can I do that? > > Le Vendredi 07 Juillet 2006 13:53, Jeff Whitaker a =C3=A9crit=C2=A0: > > Lionel Roubeyrie wrote: > > > Hi all, > > > Is it possible to import colormap file from GMT (.cpt) to basemap? If > > > yes how can we do that? > > > Thanks > > > > Lionel: I had included the GMT colormaps in matplotlib, but had to take > > them out because of licensing issues. If you want to put them back in, > > put the attached file in your matplotlib install directory > > <sys.prefix>/lib/python2.4/site-packages/matplotlib. Then use a text > > editor to add the following lines to _cm.py (in the same directory) > > > > from gmt_cm import addcmaps > > addcmaps(datad) > > > > right above the line > > > > # reverse all the colormaps. > > > > This will give you the colormaps > > > > GMT_gebco > > GMT_globe > > GMT_haxby > > GMT_no_green > > GMT_ocean > > GMT_polar > > GMT_red2green > > GMT_relief > > GMT_seis > > GMT_wysiwyg > > > > and the corresponding reversed colormaps (with '_r' appended to the > > name). > > > > > > -Jeff =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |
|
From: Eric F. <ef...@ha...> - 2006-07-18 17:51:48
|
Lionel,
Assuming you have the current version of mpl, use the "extend" kwarg:
colorbar properties:
extend=3D'neither', 'both', 'min', 'max'
If not 'neither', make pointed end(s) for out-of-ran=
ge
values. These are set for a given colormap using th=
e
colormap set_under and set_over methods.
If the colorbar is attached to a filled contour plot, however, you do=
=20
not need to specify this kwarg in the colorbar call because it will b=
e=20
grabbed from the ContourSet object.
Eric
Lionel Roubeyrie wrote:
> HI,
> how do you set the arrows on the bottom and the top of your colorba=
r? I don't=20
> find any option for that?
> Thanks
>=20
> Le Vendredi 07 Juillet 2006 10:11, dd...@ja... a =C3=A9cr=
it :
>=20
>>On Friday 07 July 2006 4:11 pm, Lionel Roubeyrie wrote:
>>
>>>Hi all,
>>>Is it possible to import colormap file from GMT (.cpt) to basemap?
>>>If yes how can we do that?
>>>Thanks
>>
>>It's possible. Here's how I've been doing it.
>>
>>(1) I use the gmtcolormapPylab function defined in:
>>http://sourceforge.net/mailarchive/message.php?msg_id=3D11255878
>>
>>(2) Using the above function and a GMT cpt file (e.g.
>>GMT_no_green.cpt), I set a color dictionary as:
>>cdict =3D gmtcolormapPylab("GMT_no_green")
>>
>>(3) I define a colormap using:
>>mycmap =3D cm.colors.LinearSegmentedColormap("GMT_no_green",cdict,2=
56)
>>
>>(4) I apply the above using cmap=3Dmycolormap in contourf or pcolor=
mesh.
>>
>>By the way, in case you don't know of the following site, it has an
>>exhaustive selection of color palettes: http://cpt-city.org.uk/
>>
>>I've also attached an example of a basemap image using a cpt from t=
he
>>above site. Masked values not defined by the colormap are shown in
>>gray.
>=20
>=20
|