我正在尝试指定在散点图中为序列放置标记的频率。在网上搜索时,我发现了markevery,但尽管有文档和其他示例,我还是搞不懂。有人能告诉我如何使用散点图的markevery吗? 以下是我的最新消息:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.lines as lines
from matplotlib import cm
import csv
import itertools
callSignList = []
xList = []
yList = []
timeList = []
#prepare the plot
fig = plt.figure(figsize=(18,13))
ax = fig.add_subplot(111)
ax.set_title("Sim Time",fontsize=14)
ax.set_xlabel("X",fontsize=12)
ax.set_ylabel("Y",fontsize=12)
ax.grid(True,linestyle='-',color='0.75')
cNorm = colors.Normalize(vmin=0, vmax=3600)
marker = itertools.cycle(('o', '^', '+', '8', 's', 'p', 'x'))
path = "C:\\Users\\otherDirectories\\"
searchString = "timeToGo.csv"
csvFile = open(path + searchString, "rb")
reader = csv.reader(csvFile)
currentCallsign = ""
firstItem = 1
for row in reader:
if float(row[3]) < 1 : continue
else:
if currentCallsign == row[0]:
callSignList.append(row[0])
xList.append(float(row[1]))
yList.append(float(row[2]))
timeList.append(float(row[3]))
currentCallsign = row[0]
#print row[0], row[1], row[2], row[3]
else:
if firstItem == 1 :
callSignList.append(row[0])
xList.append(float(row[1]))
yList.append(float(row[2]))
timeList.append(float(row[3]))
currentCallsign = row[0]
firstItem = 0
else:
x = xList
y = yList
#This is where I have problems withmarkevery
timePlot = ax.scatter(x, y, s=50, c=timeList, marker = marker.next(), edgecolors='none', norm=cNorm, cmap = cm.jet) #cm.Spectral_r
fig.subplots_adjust(top=0.90, bottom=0.15, hspace=0.25,) #left=0.07, right=0.95)
#Annotations
ax.annotate('ARC shares plan', xy=(400, 300), xytext=(500, 1.5), arrowprops=dict(facecolor='black', shrink=0.05),)
del callSignList[:]
del xList[:]
del yList[:]
del timeList[:]
callSignList.append(row[0])
xList.append(float(row[1]))
yList.append(float(row[2]))
timeList.append(float(row[3]))
currentCallsign = row[0]
csvFile.close()
# Now adding the colorbar
cax = fig.add_axes([0.15, 0.06, 0.7, 0.05])
#The numbers in the square brackets of add_axes refer to [left, bottom, width, height],
#where the coordinates are just fractions that go from 0 to 1 of the plotting area.
cbar = fig.colorbar(timePlot, cax, orientation='horizontal')
cbar.set_label('Relative Simulation Time')
plt.show()
读取的csv文件如下所示:
AMF2052,104.48336275.6281208
AMF2052104.48341275.628021209
AMF937277.02786191.210862267
[。。。更多行…]
我得到以下错误:
^{pr2}$有什么我忘了包括的吗?我试着玩玩
markerFrequency = lines.Line2D.set_markevery(markerever=20)
但这也没用。在
任何帮助都将不胜感激。在
谢谢!在
目前没有回答
相关问题 更多 >
编程相关推荐