擅长:python、mysql、java
<p>这可以很容易地扩展到其他功能。我对空间的度量是用字符而不是像素来表示的(这就是max==chars(或pixels))的原因。<br/>
只适用于正值。在</p>
<pre><code>import math
def scale(myval, mode='lin'):
steps = 7
chars = max = 10 * steps
if mode=='log':
val = 10 * math.log10(myval)
else:
val = myval
coord = []
count = 0
not_yet = True
for i in range(steps):
for j in range(10):
count += 1
if val <= count and not_yet:
coord.append('V')
not_yet = False
pos = count
elif j==9:
coord.append('|')
else:
coord.append('*')
graph = ''.join(coord)
text = 'graph %s\n\n%s\nvalue = %5.1f rel.pos. = %5.2f\n'
print text % (mode, graph, myval, chars * pos/max)
scale(50, 'lin')
scale(50, 'log')
</code></pre>
<p><img src="https://i.stack.imgur.com/Facyu.png" alt="enter image description here"/></p>
<p>希望以上不是FOO plotlib。但该死的!真是这样!:-)</p>