May-20-2018, 06:51 AM
I am asked to extract data from a file and draw those coordinates on the background picture of a map by using the module marplotlib.
I have two major issues.
1.I am almost there.if I put plt.show respectively under plot function, output diagrams are what I want.like this.
And here is my entire function.
I have two major issues.
1.I am almost there.if I put plt.show respectively under plot function, output diagrams are what I want.like this.
plt.imshow(mpimg.imread('map.png'),extent = (149.105, 149.130, -35.29, -35.27) ) plt.show() plt.scatter(latitude, longtitude) plt.show() plt.show()however, if I put those in comment and used only 1 plt.show function at the end of the whole function, all the scatter becomes only one dot.
plt.imshow(mpimg.imread('map.png'),extent = (149.105, 149.130, -35.29, -35.27) ) #plt.show() plt.scatter(latitude, longtitude) #plt.show() plt.show()2.In addition to the first problem, if I add argument 'extent' to my imshow function, the background picture would be gone in the output.
plt.imshow(mpimg.imread('map.png'),extent = (149.105, 149.130, -35.29, -35.27) )
And here is my entire function.
def map_of_sighting(altas_data): """this function is used to iterate through the data and extract the values of latitude and longtitude from each sighting,then these values will be ploted on the map""" starting_index = 1 latitude = [] longtitude = [] while starting_index < len(altas_data): float_latitude = float(altas_data[starting_index][1]) latitude.append(float_latitude) float_longtitude = float(altas_data[starting_index][2]) longtitude.append(float_longtitude) starting_index = starting_index + 1 plt.imshow(mpimg.imread('map.png'),extent = (149.105, 149.130, -35.29, -35.27) ) #plt.show() plt.scatter(latitude, longtitude) #plt.show() plt.show()I am grateful for any help.