{"id":599,"date":"2026-05-07T18:40:40","date_gmt":"2026-05-07T10:40:40","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=599"},"modified":"2026-03-24T02:07:04","modified_gmt":"2026-03-24T02:07:04","slug":"how-to-use-a-colormap-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-a-colormap-using-xlwings\/","title":{"rendered":"How To Use a Colormap Using xlwings?"},"content":{"rendered":"<p style=\"margin: 0in; font-size: 16.0pt;\"><span lang=\"zh-CN\" style=\"font-family: 'Microsoft YaHei';\">\u3010<\/span><span lang=\"en-US\" style=\"font-weight: bold; font-family: Calibri;\">Method<\/span><span lang=\"zh-CN\" style=\"font-family: 'Microsoft YaHei';\">\u3011<\/span><\/p>\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"419\" height=\"232\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image.png\" alt=\"\" class=\"wp-image-1427\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image.png 419w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image-300x166.png 300w\" sizes=\"auto, (max-width: 419px) 100vw, 419px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Name<\/td><td>Description<\/td><td>Color Bar<\/td><\/tr><tr><td>parula<\/td><td>Gradient between blue, cyan, orange, and yellow<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/4142261f-ba40-4ec6-b500-ab5b2e4d6d56\" width=\"220\" height=\"12\"><\/td><\/tr><tr><td>turbo<\/td><td>Gradient between blue and red<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/3b6d4fa3-cee1-47bb-b09d-3f059b6a12f8\" width=\"217\" height=\"9\"><\/td><\/tr><tr><td>hsv<\/td><td>Hue component variation in the HSV color model<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/9c8cd929-cf99-42f6-9c10-0dfb2e6cab81\" width=\"217\" height=\"12\"><\/td><\/tr><tr><td>hot<\/td><td>Gradient between black, red, orange, yellow, and white<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/88b3b765-e64e-445e-9943-3fa60898bff7\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>cool<\/td><td>Gradient between cyan and magenta<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/9e281ac1-cd2d-4ab6-b628-fe4c208c4760\" width=\"217\" height=\"13\"><\/td><\/tr><tr><td>spring<\/td><td>Gradient between magenta and yellow<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/f3a157ce-2962-471d-b9bb-52d777c24a71\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>summer<\/td><td>Gradient between green and yellow<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/372edfff-bcba-4f14-9e61-1e4c40f4d7ac\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>autumn<\/td><td>Gradient from red to orange-yellow, yellow<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/ba75e20c-d80d-4825-8761-5bc695eed267\" width=\"220\" height=\"12\"><\/td><\/tr><tr><td>winter<\/td><td>Gradient between blue and green<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/0a1f6c13-e5db-4a61-9718-0a825cc42aea\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>gray<\/td><td>Linear grayscale color lookup table<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/bd8f48fc-fb1e-44ec-828e-0e05bfb71ad5\" width=\"220\" height=\"12\"><\/td><\/tr><tr><td>bone<\/td><td>Gray color lookup table with a higher blue component<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/5ad05f20-c835-49a2-8dd5-073d11b638f9\" width=\"220\" height=\"12\"><\/td><\/tr><tr><td>copper<\/td><td>Gradient between black and bright copper<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/00dbae5a-4d49-45e4-9a55-c1b690a9bdad\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>pink<\/td><td>Gradient between magenta and white<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/61f81b92-b400-4a15-8075-00fdd457184e\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>sky<\/td><td>Gradient between white and sky blue<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/2def8dab-69d9-4c29-afd0-515886c11d32\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>abyss<\/td><td>Gradient between deep blue and sky blue<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/3f4d8ec5-d8dc-4e0a-b017-9ffc9f116f07\" width=\"219\" height=\"12\"><\/td><\/tr><tr><td>jet<\/td><td>Gradient between blue, cyan, yellow, orange-red, and red<\/td><td><img loading=\"lazy\" decoding=\"async\" src=\"blob:https:\/\/xlwings.net\/4e536dca-e249-48e0-a321-55dc4c3f3d81\" width=\"219\" height=\"13\"><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"263\" height=\"165\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image-2.jpeg\" alt=\"\" class=\"wp-image-1430\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"259\" height=\"165\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image-3.jpeg\" alt=\"\" class=\"wp-image-1431\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"259\" height=\"162\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image-1.jpeg\" alt=\"\" class=\"wp-image-1429\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"257\" height=\"161\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/image.jpeg\" alt=\"\" class=\"wp-image-1428\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u3010<strong>Example<\/strong>\u3011<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\nimport os\n\ndef set_style(cht):\n    cht.ChartArea.Format.Line.Visible=False\n    cht.PlotArea.Format.Fill.Visible=False\n    cht.PlotArea.Format.Line.Visible=True\n    cht.PlotArea.Format.Line.ForeColor.RGB=xw.utils.rgb_to_int((200,200,200))\n    #cht.PlotArea.Format.Line.ForeColor.ObjectThemeColor = msoThemeColorText1\n    ax1=cht.Axes(1)\n    ax2=cht.Axes(2)\n    ax1.HasTitle=True\n    ax1.AxisTitle.Text='Categories'\n    ax1.AxisTitle.Font.Size=10\n    ax1.TickLabels.Font.Size=8\n    #ax1.TickLabels.NumberFormat='0.00'\n    ax1.HasMajorGridlines=False\n    ax2.HasTitle=True\n    ax2.AxisTitle.Text='Values'\n    ax2.AxisTitle.Font.Size=10\n    ax2.TickLabels.Font.Size=8\n    ax2.HasMajorGridlines=False\n    cht.HasTitle=True\n    #cht.ChartTitle.Caption='Plot'\n    #cht.ChartTitle.Font.Size=12\n\nroot=os.getcwd()\napp=xw.App(visible=True,add_book=False)\nwb=app.books.open(root+r'\/data.xlsx',read_only=False)\nsht=wb.sheets('Sheet1')\n\nsht.api.Range('A2:B9').Select()\nshp=sht.api.Shapes.AddChart2(-1,xw.constants.ChartType.xlColumnClustered,20,20,350,250,True)\ncht=shp.Chart\ncht.ChartGroups(1).GapWidth=50\n\ncm=wb.sheets('parula').range('A1:C256').value\n\nfor i in range(8):\n    count=int((i+1)\/8*256)\n    if count==256:\n      r=int(cm&#91;255]&#91;0])\n      g=int(cm&#91;255]&#91;1])\n      b=int(cm&#91;255]&#91;2])\n    else:\n      r=int(cm&#91;count]&#91;0])\n      g=int(cm&#91;count]&#91;1])\n      b=int(cm&#91;count]&#91;2])\n\n    cht.SeriesCollection(1).Points(i+1).Format.Fill. \\\n    ForeColor.RGB=xw.utils.rgb_to_int((r,g,b))\n\nset_style(cht)\n\n#wb.save()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"756\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/3-03.jpg\" alt=\"\" class=\"wp-image-1433\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/3-03.jpg 880w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/3-03-300x258.jpg 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/05\/3-03-768x660.jpg 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-599","post","type-post","status-publish","format-standard","hentry","category-xlwings-advanced-chart"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=599"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/599\/revisions"}],"predecessor-version":[{"id":1434,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/599\/revisions\/1434"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}