Python Forum
Why there is no any input of the picture?
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why there is no any input of the picture?
#1
I have to use the module matplotlib to plot a scatter graph on the map.
here is my codes
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):
        latitude.append(altas_data[i][0])
        longtitude.append(altas_data[i][1])
        i=i+1
    plt.imshow(mpimg.imread('map.png'),extent = [149.105, 149.130, -35.29, -35.27])
    plt.scatter(latitude, longtitude)
    plt.show()
it can be run, however, there is no any input of picture, i ran my codes in Pycharm and Jupyter notebook, it was the same situation.I am grateful for any help. Thanks in advance.
Reply
#2
This is just a function definition.It will mot produce any result unless you call it. Note that you need to pass some data when calling it (that is atlas_data)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(May-19-2018, 05:17 AM)buran Wrote: This is just a function definition.It will mot produce any result unless you call it. Note that you need to pass some data when calling it (that is atlas_data)
I had modified my function and also called the functions,i still have two major issues.
1.If i put plt.show under plt.imshow and plt.scatter respectively, two diagrams outputted are what I want, however If i only put pat.show there, the scatter dot become only one dot. i tried, but there is no way to get rid of this issue.

2.if i put my extent argument in imshow function, the background picture which is a map will disappear,why is it so? I really have no idea.

here is my codes

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()

map_of_sighting(altas_data)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo How to find axiom of this picture DerbyHarrington 2 1,717 Mar-15-2020, 12:02 PM
Last Post: DerbyHarrington
  How to modify and get the same picture vokoyo 1 2,165 Jul-07-2019, 11:37 AM
Last Post: dataman

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020