那里有一个很好的命令行UNIX图表/图形/绘图工具吗?我正在寻找能在ASCII图上绘制xy点的东西.
只是为了澄清,我正在寻找能够输出ASCII图形的东西(如ascii-art样式),所以我可以在交互式shell会话中使用它而不需要X.
我在我的家庭服务器上运行 Ubuntu 14.04(服务器版),并且使用 TkAgg 作为后端安装了 Python 2.7.6 和 matplotlib 1.3.1。我通过 ssh -Y 连接到它。
我遇到的问题是绘图对象的创建非常慢。例如:
import matplotlib.pyplot as plt
x=[0,1,2,3,4]
y=[0,1,4,9,16]
plt.plot(x,y)
Run Code Online (Sandbox Code Playgroud)
该代码的运行时间大约为 10 秒,而本应只需要几分之一秒。请注意,它甚至没有显示情节,如果我添加plt.show()它,它在时间上没有显着差异。在 python 解释器中或从文件中运行代码也没有什么区别。一旦我等待足够长的时间,该图就会很好地显示在我的本地屏幕上。另外,绘制 5 点或 50 点似乎没有任何区别。
有任何想法吗?
我正在研究ML / Theano,最近遇到了这个脚本:https ://gist.github.com/notmatthancock/68d52af2e8cde7fbff1c9225b2790a7f 玩起来很酷。和所有ML研究人员一样,我最近升级到了服务器,虽然功能更强大,但它也给我带来了问题。
该脚本很长,但是以以下代码结尾:
def plot_stuff(inputs, outputs, losses, net_func, n_hidden):
fig,axes = plt.subplots(1,2,figsize=(12,6))
axes[0].plot(np.arange(losses.shape[0])+1, losses)
axes[0].set_xlabel('iteration')
axes[0].set_ylabel('loss')
axes[0].set_xscale('log')
axes[0].set_yscale('log')
x,y = np.mgrid[inputs[:,0].min():inputs[:,0].max():51j, inputs[:,1].min():inputs[:,1].max():51j]
z = net_func( np.c_[x.flatten(), y.flatten()] ).reshape(x.shape)
axes[1].contourf(x,y,z, cmap=plt.cm.RdBu, alpha=0.6)
axes[1].plot(inputs[outputs==0,0], inputs[outputs==0,1], 'or')
axes[1].plot(inputs[outputs==1,0], inputs[outputs==1,1], 'sb')
axes[1].set_title('Percent missclassified: %0.2f%%' % (((net_func(inputs)>0.5) != outputs.astype(np.bool)).mean()*100))
fig.suptitle('Shallow net with %d hidden units'%n_hidden)
plt.show()
if __name__=='__main__':
n_hidden = 40
inputs, outputs = gen_data(n_samples_per_class=100)
losses, net_func = train_neural_network(inputs=inputs, outputs=outputs, n_hidden=n_hidden, n_iters=int(2000), learning_rate=0.1)
plot_stuff(inputs, outputs, losses, net_func, n_hidden)
Run Code Online (Sandbox Code Playgroud)
生成以下图表:
当我尝试在服务器上运行它时,它是一个只有命令行而没有屏幕的服务器,我可以预料地收到此错误:
fedora@ip-173-33-18-911:~/scripting/spiral$ …Run Code Online (Sandbox Code Playgroud) 我有一个band1如下所示的字典,我想根据字典中每个列表的第一个和最后一个元素打印出一个图表.x轴上每个列表的第一个元素是频率,最后一个元素是接收强度,应该在y轴上.例如,10812的强度为16等
band1 = {'channel1': [10564, 2112.8, 1922.8, 0],
'channel10': [10787, 2157.4, 1967.4, 11],
'channel11': [10812, 2162.4, 1972.4, 16],
'channel12': [10837, 2167.4, 1977.4, 46],
'channel2': [10589, 2117.8, 1927.8, 29],
'channel3': [10612, 2122.4, 1932.4, 0],
'channel4': [10637, 2127.4, 1937.4, 40],
'channel5': [10662, 2132.4, 1942.4, 54],
'channel6': [10687, 2137.4, 1947.4, 0],
'channel7': [10712, 2142.4, 1952.4, 50],
'channel8': [10737, 2147.4, 1957.4, 19],
'channel9': [10762, 2152.4, 1962.4, 24]}
Run Code Online (Sandbox Code Playgroud)
我没有问题排序这个,channel1 - > channel12但是有什么好方法可以打印一个漂亮的图表,字典中的条目数量可以随着或多或少的频道而变化.
matplotlib ×3
python ×3
charts ×1
command-line ×1
graph ×1
headless ×1
python-2.7 ×1
theano ×1
unix ×1