[英]Making a list from data points which already have been plotted
I'm trying to list the data points/lines that i already plotted but i can't get it to work.我正在尝试列出我已经绘制的数据点/线,但我无法让它工作。 I tried several things but unfortunatly without results.
我尝试了几件事,但不幸的是没有结果。
What i want is that i get a list of the data points that i just plotted.我想要的是我得到一个我刚刚绘制的数据点的列表。 After that i want to be able to create multiple lines with the help of the list instead of all tiny lines what happens now.
之后,我希望能够在列表的帮助下创建多行,而不是现在发生的所有小行。 the plotting is done in these two lines:
绘图是在这两行中完成的:
this one plots vertical lines ax.plot([i+1.5,i+1.5], [j+.5,j+1.5], linewidth=3,linestyle='-',color='#000000')
这个绘制垂直线
ax.plot([i+1.5,i+1.5], [j+.5,j+1.5], linewidth=3,linestyle='-',color='#000000')
and this one plots horizontal lines ax.plot([i+.5,i+1.5], [j+1.5,j+1.5], linewidth=3,linestyle='-',color='#000000')
这个绘制水平线
ax.plot([i+.5,i+1.5], [j+1.5,j+1.5], linewidth=3,linestyle='-',color='#000000')
can anybody help me out?有人可以帮帮我吗? below is a part of my code.
下面是我的代码的一部分。
for iIsochrone in range(int(np.nanmin(array)),int(np.nanmax(array)), Wavelinetime):
#zorgt voor golflijn met stappen van 10 vertikaal
for i in range(fileObject.numberOfColumnsInArray-1):
for j in range(fileObject.numberOfRowsInArray):
if (array[j, i]<=iIsochrone and array[j, i+1]>iIsochrone) or (array[j, i]>iIsochrone and array[j, i+1]<=iIsochrone):
ax.plot([i+1.5,i+1.5], [j+.5,j+1.5], linewidth=3,linestyle='-',color='#000000') #rechte blockline
#zorgt voor golflijn met stappen van 10 horizontaal
for i in range(fileObject.numberOfColumnsInArray):
for j in range(fileObject.numberOfRowsInArray-1):
if (array[j, i]<=iIsochrone and array[j+1, i]>iIsochrone) or (array[j, i]>iIsochrone and array[j+1, i]<=iIsochrone):
ax.plot([i+.5,i+1.5], [j+1.5,j+1.5], linewidth=3,linestyle='-',color='#000000') #rechte blockline```
As detailed in this SO post , you could use the get_lines()
method to extract data points from your plot 如此 SO post中所述,您可以使用
get_lines()
方法从 plot 中提取数据点
gca().get_lines()[n].get_xydata()
EDIT:编辑:
Another option would be to save the values before they are being plotted.另一种选择是在绘制之前保存这些值。
For instance, since you are working with lists, you could save your i values to a list called mylisti and your j values to another list called mylistj :例如,由于您正在使用列表,您可以将i值保存到名为mylisti的列表中,将j值保存到另一个名为mylistj的列表中:
mylisti=[]
mylistj=[]
for iIsochrone in range(int(np.nanmin(array)),int(np.nanmax(array)), Wavelinetime):
#zorgt voor golflijn met stappen van 10 vertikaal
for i in range(fileObject.numberOfColumnsInArray-1):
for j in range(fileObject.numberOfRowsInArray):
if (array[j, i]<=iIsochrone and array[j, i+1]>iIsochrone) or (array[j, i]>iIsochrone and array[j, i+1]<=iIsochrone):
mylisti+=[i+1.5,i+1.5]
mylistj+=[j+.5,j+1.5]
ax.plot([i+1.5,i+1.5], [j+.5,j+1.5], linewidth=3,linestyle='-',color='#000000') #rechte blockline
#zorgt voor golflijn met stappen van 10 horizontaal
for i in range(fileObject.numberOfColumnsInArray):
for j in range(fileObject.numberOfRowsInArray-1):
if (array[j, i]<=iIsochrone and array[j+1, i]>iIsochrone) or (array[j, i]>iIsochrone and array[j+1, i]<=iIsochrone):
ax.plot([i+.5,i+1.5], [j+1.5,j+1.5], linewidth=3,linestyle='-',color='#000000') #rechte blockline```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.