https://github.com/muisedestiny/getcolorbarfromimage
https://github.com/muisedestiny/getcolorbarfromimage
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/muisedestiny/getcolorbarfromimage
- Owner: MuiseDestiny
- Created: 2021-06-06T13:29:39.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-07T02:07:19.000Z (about 5 years ago)
- Last Synced: 2025-06-01T01:15:10.606Z (about 1 year ago)
- Language: Jupyter Notebook
- Size: 540 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# getColorbarFromImage
## 用法
截图,然后运行本代码,颜色自动复制到剪贴板,一个列表形式
截图时候尽量别截其它无关部分,不然容易误判的
## 示例

这对编程绘图十分有用!
、
[](https://img.wang/image/qqjie-tu-20210606220030.oUK9f)
## 用途
如matplotlib、cartopy等
```python
fig, ax = plt.subplots(figsize=(12, 0.36), dpi=150)
cmap = mpl.colors.ListedColormap(hex_colors[1:-1])
cmap.set_under(hex_colors[0])
cmap.set_over(hex_colors[-1])
plt.colorbar(mpl.cm.ScalarMappable(cmap=cmap, norm=mpl.colors.Normalize(0, 10)),
orientation='horizontal', extend='both', cax=ax)
```
## 需要的库库
```python
from PIL import ImageGrab
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib as mpl
import pyperclip
```