当前位置: 首页>>代码示例>>Python>>正文


Python LineCollection.set_antialiased方法代码示例

本文整理汇总了Python中matplotlib.collections.LineCollection.set_antialiased方法的典型用法代码示例。如果您正苦于以下问题:Python LineCollection.set_antialiased方法的具体用法?Python LineCollection.set_antialiased怎么用?Python LineCollection.set_antialiased使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.collections.LineCollection的用法示例。


在下文中一共展示了LineCollection.set_antialiased方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_antialiased [as 别名]
def plot(ax, x, y, time, sim_type):
	assert(len(x) == len(y) == len(time))

	l = len(time)
	if use_hf_coloration:
		time_to_grayscale = 0.8 / 23.6 # for HF coloring
	else:
		time_to_grayscale = 0.8 / time[l-1]
	colors = []
	for i in range(l-1):
		if use_hf_coloration:
			color = get_hf_color(time[i])  # time[] is really HF
		else:
			g = 0.8 - (time[i] * time_to_grayscale)**2.0
			if sim_type == 'driven':
				color = (g, 1.0, g, 0.8)
			else:
				color = (g, g, 1.0, 1.0)
		colors.append(color)
	
	points = zip(x,y)
	segments = zip(points[:-1], points[1:])
	lc = LineCollection(segments, colors=colors)
	lc.set_alpha(1.0)
	lc.set_linewidth(1.0)
	lc.set_antialiased(True)
	ax.add_collection(lc)
	if use_hf_coloration:
		end_points.append((x[l-1], y[l-1], get_hf_color(time[l-1])))
	else:
		end_points.append((x[l-1], y[l-1], COLOR[sim_type]))
开发者ID:rockhowse,项目名称:polyworld-modified,代码行数:33,代码来源:plot_traces.py

示例2: plotter

# 需要导入模块: from matplotlib.collections import LineCollection [as 别名]
# 或者: from matplotlib.collections.LineCollection import set_antialiased [as 别名]
def plotter(choice, numNeurons, numTimeSteps, maxNeurons, maxTimeSteps, reverse, numInputNeurons, colorNeurons, redStart, redEnd, greenStart, greenEnd, blueStart, blueEnd, eatNeuron, mateNeuron, fightNeuron, moveNeuron, yawNeuron, label, behaviorLabels, inputLabels):
	rhythm_file = open_file(choice, "r")
	line = next_line(rhythm_file)
	line = next_line(rhythm_file)
	figwidth = 12.0
	figheight = 8.0

	fig = pylab.figure(figsize=(figwidth,figheight))

	ax = fig.add_subplot(111)
	ax.set_xlim(0.5, maxTimeSteps+0.5)
	ax.set_ylim(maxNeurons-0.5, -0.5)
	pylab.title(label)
	pylab.ylabel('Neuron Index')
	pylab.xlabel('Time Step')

	linewidth = 0.715 * fig.get_figwidth() * fig.get_dpi() / maxTimeSteps

	for time in range(numTimeSteps):
		x = []
		y = []
		colors = []
		for neuron in range(numNeurons):
			activ = line.split()
			x.append(time+1)			  
			y.append(neuron-0.5)
			activation = float(activ[1])
			if reverse:
				activation = 1.0 - activation
			if colorNeurons:
				if neuron in range(redStart, redEnd+1):
					colors.append((activation, activation*ALT_COLOR_MAX, activation*ALT_COLOR_MAX, 1.0))
				elif neuron in range(greenStart, greenEnd+1):
					colors.append((activation*ALT_COLOR_MAX, activation, activation*ALT_COLOR_MAX, 1.0))
				elif neuron in range(blueStart, blueEnd+1):
					colors.append((activation*ALT_COLOR_MAX, activation*ALT_COLOR_MAX, activation, 1.0))
				elif neuron == eatNeuron:
					colors.append((activation*ALT_COLOR_MAX, activation, activation*ALT_COLOR_MAX, 1.0))
				elif neuron == mateNeuron:
					colors.append((activation*ALT_COLOR_MAX, activation*ALT_COLOR_MAX, activation, 1.0))
				elif neuron == fightNeuron:
					colors.append((activation, activation*ALT_COLOR_MAX, activation*ALT_COLOR_MAX, 1.0))
				elif neuron == yawNeuron:
					colors.append((activation, activation, activation*ALT_COLOR_MAX, 1.0))
				else:
					colors.append((activation, activation, activation, 1.0))
			else:
				colors.append((activation, activation, activation, 1.0))
			line = next_line(rhythm_file)
		x.append(time+1)
		y.append(neuron+0.5)
		colors.append((activation, activation, activation, 1.0))
		points = zip(x, y)
		segments = zip(points[:-1], points[1:])
		lc = LineCollection(segments, colors=colors)
		lc.set_alpha(1.0)
		lc.set_linewidth(linewidth)
		lc.set_antialiased(False)
		ax.add_collection(lc)

	rhythm_file.close()

	if behaviorLabels:
		matplotlib.pyplot.text(maxTimeSteps+1.5, eatNeuron, "Eat", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, mateNeuron, "Mate", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, fightNeuron, "Fight", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, moveNeuron, "Move", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, yawNeuron, "Turn", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, yawNeuron+1, "Light", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, yawNeuron+2, "Focus", weight="ultralight", size="small", va="center")
	
	if inputLabels:
		matplotlib.pyplot.text(maxTimeSteps+1.5, 0, "Random", weight="ultralight", size="small", va="center")
		matplotlib.pyplot.text(maxTimeSteps+1.5, 1, "Health", weight="ultralight", size="small", va="center")
		for neuron in range(redStart, redEnd+1):
			matplotlib.pyplot.text(maxTimeSteps+1.5, neuron, "R", weight="ultralight", size="small", va="center")
		for neuron in range(greenStart, greenEnd+1):
			matplotlib.pyplot.text(maxTimeSteps+1.5, neuron, "G", weight="ultralight", size="small", va="center")
		for neuron in range(blueStart, blueEnd+1):
			matplotlib.pyplot.text(maxTimeSteps+1.5, neuron, "B", weight="ultralight", size="small", va="center")
开发者ID:rockhowse,项目名称:polyworld-modified,代码行数:82,代码来源:plotNeuralRhythms.py


注:本文中的matplotlib.collections.LineCollection.set_antialiased方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。