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')
and this one plots horizontal lines 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
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 :
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```
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.