简体   繁体   English

从已经绘制的数据点制作列表

[英]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.

相关问题 如何从包含许多已排序列表的列表中获取排序列表? - How to get a sorted list from a list which contains many list that have already been sorted? 如何从使用markevery参数绘制的线中提取标记数据点? - How to extract marker data points from a line plotted with markevery argument? 在matplotlib中重置已绘制散点的点 - resetting points of an already plotted scatter in matplotlib Matplotlib - 仅使用 Y 坐标突出显示已绘制图形中的点 - Matplotlib - Highlight points from already plotted graph using only Y-coordinate matplotlib 数据点绘制但它们之间没有线? - matplotlib data points plotted but no line between them? 从 seaborn swarmplot 中获取绘制点的跨度 - Obtaining span of plotted points from seaborn swarmplot 我如何从方法列表中得知哪些方法已在该类中定义,哪些已被继承? - How do i tell from a list of methods, which ones have been defined in that class and those that have been inherited? Python-Matplotlib-保持轴平整和线性,并在网格上绘制点 - Python - Matplotlib - Keep axes even and linear and have points plotted on grid 如果绘制了多个图形,如何获得该线的 label? - How to get the line's label if multiple graphs have been plotted? 来自已经分箱的数据的直方图,我有分箱和频率值 - Histogram from data which is already binned, I have bins and frequency values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM