Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
minV = 0
maxV = 0
files = options.summary.split(",")
nums = readValues(files, options.verbose, options.measure)
times = readValues(files, options.verbose, "time")
for f in files:
maxV = max(maxV, len(nums[f]))
range(minV, maxV + 1)
fig, ax = helpers.openFigure(options)
for i, f in enumerate(files):
v = sumolib.output.toList(nums[f], options.measure)
t = sumolib.output.toList(times[f], "time")
c = helpers.getColor(options, i, len(files))
plt.plot(t, v, label=helpers.getLabel(f, i, options), color=c)
helpers.closeFigure(fig, ax, options)
options.columns = [int(i) for i in options.columns.split(",")]
nums = readValues(options.input, options.verbose, options.columns)
for f in nums:
maxV = max(maxV, len(nums[f]))
ts = range(minV, maxV + 1)
fig, ax = helpers.openFigure(options)
for i in nums:
v = nums[i]
ci = i
if options.columns is not None:
ci = options.columns.index(i)
c = helpers.getColor(options, ci, len(nums))
l = helpers.getLabel(str(i), ci, options)
plt.plot(ts[0:len(v)], v, label=l, color=c)
helpers.closeFigure(fig, ax, options)
if options.output:
# If we have a "%s" in the name of the output then replace it with the
# interval begin of the current interval
expandedOutputNames = optOutputNames
if expandedOutputNames.find('%s') >= 0:
expandedOutputNames = expandedOutputNames.replace("%s", str(t))
# Can be used to print additional text in the figure:
#
# m, s = divmod(int(t), 60)
# h, m = divmod(m, 60)
# timeStr = "%02d:%02d:%02d" % (h, m, s)
# ax.text(0.2, 0.2, timeStr, bbox={
# 'facecolor': 'white', 'pad': 10}, size=16)
helpers.closeFigure(fig, ax, options, False, expandedOutputNames)
return 0
for node in tlsn[tid]:
x += node._coord[0]
y += node._coord[1]
n = n + 1
x = x / n
y = y / n
tlspX.append(x)
tlspY.append(y)
fig, ax = helpers.openFigure(options)
ax.set_aspect("equal", None, 'C')
helpers.plotNet(net, {}, {}, options)
plt.plot(tlspX, tlspY, options.color, linestyle='.',
marker='o', markersize=options.width)
options.nolegend = True
helpers.closeFigure(fig, ax, options)
if options.verbose:
print("Reading network from '%s'" % options.net)
net = sumolib.net.readNet(options.net)
selection = sumolib.files.selection.read(options.selection)
colors = {}
widths = {}
for e in selection["edge"]:
colors[e] = options.selectedColor
widths[e] = options.selectedWidth
fig, ax = helpers.openFigure(options)
ax.set_aspect("equal", None, 'C')
helpers.plotNet(net, colors, widths, options)
options.nolegend = True
helpers.closeFigure(fig, ax, options)
rect.set_color(colors[i])
rect.set_edgecolor('k')
plt.ylim(0, x)
plt.yticks(ts, labels)
else:
rects = plt.bar(xs, vals, width=options.width)
for i, rect in enumerate(rects):
if options.showValues:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width() / 2., height +
options.valuesOffset, vlabels[i], ha='center', va='bottom')
rect.set_color(colors[i])
rect.set_edgecolor('k')
plt.xlim(0, x)
plt.xticks(ts, labels)
helpers.closeFigure(fig, ax, options, False)
rect.set_color(colors[i])
rect.set_edgecolor('k')
plt.ylim(0, x)
plt.yticks(ts, labels)
else:
rects = plt.bar(xs, vals, width=options.width)
for i, rect in enumerate(rects):
if options.showValues:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width() / 2., height +
options.valuesOffset, vlabels[i], ha='center', va='bottom')
rect.set_color(colors[i])
rect.set_edgecolor('k')
plt.xlim(0, x)
plt.xticks(ts, labels)
helpers.closeFigure(fig, ax, options, False)
hists[f] = h
width = binWidth / float(len(files)) * .8
offset = binWidth * .1
center = []
for j in range(0, options.bins):
center.append(binWidth * j + offset)
fig, ax = helpers.openFigure(options)
for i, f in enumerate(files):
c = helpers.getColor(options, i, len(files))
l = helpers.getLabel(f, i, options)
plt.bar(center, hists[f], width=width, label=l, color=c)
for j in range(0, options.bins):
center[j] = center[j] + width
helpers.closeFigure(fig, ax, options)