我正在尝试指定在散点图中为系列放置标记的频率。在网上搜索我发现了关于市场营销的问题,但是尽管有文档和其他例子我无法弄清楚。有人能给我一些关于如何使用散点图的市场营销的见解吗? 这就是我[更新]:
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.48336,275.628,1208
AMF2052,104.48341,275.62802,1209
AMF937,277.02786,191.21086,2267
[...更多行...]
我收到以下错误:
Traceback (most recent call last):
File "C:/Users/otherDirectories/PythonExamples/X-Y-Value_Plot_Z-SimTime_02_noSectors.py", line 58, in <module>
timePlot = ax.scatter(x, y, s=50, c=timeList, markevery=(20), marker = marker.next(), edgecolors='none', norm=cNorm, cmap = cm.jet) #cm.Spectral_r
File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 5816, in scatter
collection.update(kwargs)
File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 655, in update
raise AttributeError('Unknown property %s'%k)
AttributeError: Unknown property markevery
有什么我忘了包含的东西吗?我试着玩
markerFrequency = lines.Line2D.set_markevery(markerever=20)
但这也不起作用。
任何帮助都将不胜感激。
谢谢!