Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options, remaining_args = optParser.parse_args(args=args)
if options.input is None:
print("Error: an input file must be given")
sys.exit(1)
minV = 0
maxV = 0
if options.columns is not None:
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)
for line in fd:
v = line.strip().split(";")
if len(v) < 2:
continue
labels.append(v[0].replace("\\n", "\n"))
vals.append(float(v[1]))
total += float(v[1])
if options.revert:
labels.reverse()
vals.reverse()
colors = []
for i, e in enumerate(labels):
colors.append(helpers.getColor(options, i, len(labels)))
fig, ax = helpers.openFigure(options)
if options.nolabels:
labels = None
shadow = options.shadow
if options.percentage:
def autopct(p):
return '{:.1f}%'.format(p)
# autopct = lambda p: '{:.1f}%'.format(p)
else:
def autopct(p):
return '{:.0f}'.format(p * total / 100)
# autopct = lambda p: '{:.0f}'.format(p * total / 100)
patches, texts, autotexts = plt.pie(
vals, labels=labels, autopct=autopct, colors=colors, shadow=shadow, startangle=options.startangle)
helpers.closeFigure(fig, ax, options)
options, remaining_args = optParser.parse_args(args=args)
if options.summary is None:
print("Error: at least one summary file must be given")
sys.exit(1)
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]))
ts = 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))
l = helpers.getLabel(f, i, options)
plt.plot(t, v, label=l, color=c)
helpers.closeFigure(fig, ax, options)
options, _ = optParser.parse_args(args=args)
if options.summary is None:
print("Error: at least one summary file must be given")
sys.exit(1)
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)
return 1
if options.selection is None:
print("Error: a selection to load must be given.")
return 1
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)
if options.widthMax is not None:
maxWidthValue = options.widthMax
if options.widthMin is not None:
minWidthValue = options.widthMin
if options.logWidths:
helpers.logNormalise(widths, options.colorMax)
else:
helpers.linNormalise(widths, minWidthValue, maxWidthValue)
for e in widths:
widths[e] = options.minWidth + widths[e] * \
(options.maxWidth - options.minWidth)
if options.verbose:
print("Width values are between %s and %s" %
(minWidthValue, maxWidthValue))
fig, ax = helpers.openFigure(options)
ax.set_aspect("equal", None, 'C')
helpers.plotNet(net, colors, widths, options)
# drawing the legend, at least for the colors
norm = matplotlib.colors.LogNorm if options.logColors else matplotlib.colors.Normalize
sm = plt.cm.ScalarMappable(cmap=matplotlib.cm.get_cmap(options.colormap),
norm=norm(vmin=minColorValue, vmax=maxColorValue))
# "fake up the array of the scalar mappable. Urgh..."
# (pelson, http://stackoverflow.com/questions/8342549/matplotlib-add-colorbar-to-a-sequence-of-line-plots)
sm._A = []
plt.colorbar(sm)
# Should we also save the figure to a file / list of files (comma
# separated)?
if options.output:
if maxV is None or maxV < v:
maxV = v
speeds[e] = v
if options.minV is not None:
minV = options.minV
if options.maxV is not None:
maxV = options.maxV
# if options.logColors:
# helpers.logNormalise(colors, maxColorValue)
# else:
# helpers.linNormalise(colors, minColorValue, maxColorValue)
helpers.linNormalise(speeds, minV, maxV)
for e in speeds:
speeds[e] = helpers.getColor(options, speeds[e], 1.)
fig, ax = helpers.openFigure(options)
ax.set_aspect("equal", None, 'C')
helpers.plotNet(net, speeds, {}, options)
# drawing the legend, at least for the colors
print("%s -> %s" % (minV, maxV))
sm = matplotlib.cm.ScalarMappable(
cmap=get_cmap(options.colormap), norm=plt.normalize(vmin=minV, vmax=maxV))
# "fake up the array of the scalar mappable. Urgh..." (pelson, http://stackoverflow.com/questions/8342549/matplotlib-add-colorbar-to-a-sequence-of-line-plots)
sm._A = []
plt.colorbar(sm)
options.nolegend = True
helpers.closeFigure(fig, ax, options)
if options.widthMax is not None:
maxWidthValue = options.widthMax
if options.widthMin is not None:
minWidthValue = options.widthMin
if options.logWidths:
helpers.logNormalise(widths, options.colorMax)
else:
helpers.linNormalise(widths, minWidthValue, maxWidthValue)
for e in widths:
widths[e] = options.minWidth + widths[e] * \
(options.maxWidth - options.minWidth)
if options.verbose:
print("Width values are between %s and %s" %
(minWidthValue, maxWidthValue))
fig, ax = helpers.openFigure(options)
ax.set_aspect("equal", None, 'C')
helpers.plotNet(net, colors, widths, options)
# drawing the legend, at least for the colors
norm = matplotlib.colors.LogNorm if options.logColors else matplotlib.colors.Normalize
sm = plt.cm.ScalarMappable(cmap=matplotlib.cm.get_cmap(options.colormap),
norm=norm(vmin=minColorValue, vmax=maxColorValue))
# "fake up the array of the scalar mappable. Urgh..."
# (pelson, http://stackoverflow.com/questions/8342549/matplotlib-add-colorbar-to-a-sequence-of-line-plots)
sm._A = []
color_bar = plt.colorbar(sm)
color_bar.set_label(options.colorBarLabel)
# Should we also save the figure to a file / list of files (comma
# separated)?