企业信息管理系统案例/台州seo排名优化
这是一个点图的算法,尽管它可能是简单和天真的。当然,它的性能还远未得到实现,可以进行优化,而且输出可以有一些轴和数字。在HEIGHT = 10
WIDTH = 40
MARKER = '*'
FILL_CHARACTER = ' '
coords = [(ch[0], ch[3]) for ch in band1.values()]
# Convert to coordinates of a desired ASCII area
xmin = min(c[0] for c in coords)
xmax = max(c[0] for c in coords)
kx = (WIDTH - 1) / (xmax - xmin)
ymin = min(c[1] for c in coords)
ymax = max(c[1] for c in coords)
ky = (HEIGHT - 1) / (ymax - ymin)
acoords = [(round((c[0] - xmin) * kx),
round((c[1] - ymin) * ky)) for c in coords]
# Actually draw the graph
for y in range(HEIGHT, -1, -1):
chars = []
for x in range(WIDTH):
if (x, y) in acoords:
chars.append(MARKER)
else:
chars.append(FILL_CHARACTER)
print(''.join(chars))
结果发送至:
^{pr2}$
如果x坐标是唯一的,那么可以很容易地修改它来绘制柱形图或折线图。在
例如,对于钢筋:HEIGHT = 10
WIDTH = 40
MARKER = '*'
FILL_CHARACTER = ' '
coords = [(ch[0], ch[3]) for ch in band1.values()]
coords.sort(key=lambda ch: ch[1])
xmin = min(c[0] for c in coords)
xmax = max(c[0] for c in coords)
kx = (WIDTH - 1) / (xmax - xmin)
ymin = min(c[1] for c in coords)
ymax = max(c[1] for c in coords)
ky = (HEIGHT - 1) / (ymax - ymin)
acoords = {}
for c in coords:
x = round((c[0] - xmin) * kx)
y = round((c[1] - ymin) * ky)
if x not in acoords:
acoords[x] = y
else:
acoords[x] = max(acoords[x], y)
for y in range(HEIGHT, -1, -1):
chars = []
for x in range(WIDTH):
if acoords.get(x, 0) >= y:
chars.append(MARKER)
else:
chars.append(FILL_CHARACTER)
print(''.join(chars))
结果发送至:*
* * *
* * * *
* * * *
* * * * *
* * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * *
****************************************