以十六進位制格式提取 Matplotlib 顏色對映
若要提取十六進位制格式的 Matplotlib 顏色對映,我們可以按以下步驟進行 −
獲取彩虹顏色對映。
在彩虹顏色對映長度的範圍內進行迭代。
使用 rgb2hex 方法,將rgba 元組轉換為顏色的十六進位制表示形式。
示例
from matplotlib import cm
import matplotlib
cmap = cm.rainbow
for i in range(cmap.N):
rgba = cmap(i)
print("Hexadecimal representation of rgba:{} is {}".format(rgba, matplotlib.colors.rgb2hex(rgba)))輸出
............... ........................ .................................... Hexadecimal representation of rgba:(1.0, 0.3954512068705424, 0.2018824091570102, 1.0) is #ff6533 Hexadecimal representation of rgba:(1.0, 0.38410574917192575, 0.1958454670071669, 1.0) is #ff6232 Hexadecimal representation of rgba:(1.0, 0.37270199199091436, 0.18980109344182594, 1.0) is #ff5f30 .........................................................
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP