标签:可视化 tran efi def cmap raw off dpi 排序
为实现小程序的地图可视化做准备
#-*-coding:utf-8-*-
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle
import matplotlib as mt
/**
*生成一个指定颜色,指定大小的圆
*/
def drawCircle(color,size,name):
fig = plt.figure(figsize=(size,size))
ax = fig.add_subplot(111)
circle = Circle(xy=(0.0,0.0),radius=1,alpha=0.5,color=color)
ax.add_patch(circle)
plt.axis('off')
plt.xticks([])
plt.yticks([])
plt.axis('equal')
plt.savefig('/home/zx/'+name,dpi=50,transparent=True,bbox_inches='tight')
plt.show()
/**
*根据数据在整体数据排序的位置生成颜色
*/
def getColor(value,vmin,vmax):
norm = mt.colors.Normalize(vmin,vmax)
colorIndex = norm(value)
cmap = mt.cm.get_cmap('Spectral')
rgba = cmap(colorIndex)
return rgba
theColor = getColor(12,8,300)
drawCircle(theColor,1.2,'s1.2.png')
标签:可视化 tran efi def cmap raw off dpi 排序
原文地址:https://www.cnblogs.com/itzx/p/11266473.html