到目前为止我有这个图表,有点难看。每种类型的标记都是一种算法的精度。你知道吗
这有两个问题:
对于#1,我尝试过玩xticks,如你在下面看到的,但没有太大的成功。你知道吗
对于#2,将数据放入np.log10()
中很简单,但随后轴记号也进行了对数变换。我觉得应该有一个简单的方法来做这个日志显示(似乎是一个很正常的事情做)?你知道吗
以下是我目前的代码:
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import random
# create fake data
data = {}
data['A'] = []
data['B'] = []
data['C'] = []
n = 5
data['A'] = zip(np.random.uniform(0, 10000, size=n), np.random.uniform(0, 0.6, size=n))
data['B'] = zip(np.random.uniform(0, 200, size=n), np.random.uniform(0, 0.6, size=n))
data['C'] = zip(np.random.uniform(0, 5000, size=n), np.random.uniform(0, 0.6, size=n))
# make graph
markers = ['+', '*', 'x']
colors = ['b', 'r', 'g']
fig = plt.figure()
ax1 = fig.add_subplot(111)
plots = []
labels = []
# extract data
i = 0
for algorithm in ['A', 'B', 'C']:
results = data[algorithm]
testing = np.array([float(x[1]) for x in results if x > 0.0])
ts = np.array([int(x[0]) for x in results if x > 0.0])
color = colors[i]
marker = markers[i]
plot = ax1.scatter(ts, testing, color=color, marker=marker, s=10)
plots.append(plot)
labels.append(algorithm)
i += 1
# set axis and title
ax1.legend(plots, labels, loc='lower right')
ax1.set_xlabel("Time (sec)")
ax1.set_ylabel("Testing Accuracy")
ax1.set_title("Time versus testing accuracy")
# set axis limits
xticks, xticklabels = plt.xticks()
xmin = (3*xticks[0] - xticks[1])/2.
xmax = (3*xticks[-1] - xticks[-2])/2.
plt.xlim(xmin, xmax)
plt.xticks(xticks)
plt.ylim(0.0, 1.0)
# save to disk
plt.savefig("scatter.eps")
你为什么不这么做?你知道吗
相关问题 更多 >
编程相关推荐