Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:34:49+00:00 2026-06-17T12:34:49+00:00

Would there be a way to plot the borders of the continents with Basemap

  • 0

Would there be a way to plot the borders of the continents with Basemap (or without Basemap, if there is some other way), without those annoying rivers coming along? Especially that piece of Kongo River, not even reaching the ocean, is disturbing.

EDIT: I intend to further plot data over the map, like in the Basemap gallery (and still have the borderlines of the continents drawn as black lines over the data, to give structure for the worldmap) so while the solution by Hooked below is nice, masterful even, it’s not applicable for this purpose.

world map

Image produced by:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(8, 4.5))
plt.subplots_adjust(left=0.02, right=0.98, top=0.98, bottom=0.00)
m = Basemap(projection='robin',lon_0=0,resolution='c')
m.fillcontinents(color='gray',lake_color='white')
m.drawcoastlines()
plt.savefig('world.png',dpi=75)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:34:50+00:00Added an answer on June 17, 2026 at 12:34 pm

    Following user1868739’s example, I am able to select only the paths (for some lakes) that I want:
    world2

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    
    fig = plt.figure(figsize=(8, 4.5))
    plt.subplots_adjust(left=0.02, right=0.98, top=0.98, bottom=0.00)
    m = Basemap(resolution='c',projection='robin',lon_0=0)
    m.fillcontinents(color='white',lake_color='white',zorder=2)
    coasts = m.drawcoastlines(zorder=1,color='white',linewidth=0)
    coasts_paths = coasts.get_paths()
    
    ipolygons = range(83) + [84] # want Baikal, but not Tanganyika
    # 80 = Superior+Michigan+Huron, 81 = Victoria, 82 = Aral, 83 = Tanganyika,
    # 84 = Baikal, 85 = Great Bear, 86 = Great Slave, 87 = Nyasa, 88 = Erie
    # 89 = Winnipeg, 90 = Ontario
    for ipoly in ipolygons:
        r = coasts_paths[ipoly]
        # Convert into lon/lat vertices
        polygon_vertices = [(vertex[0],vertex[1]) for (vertex,code) in
                            r.iter_segments(simplify=False)]
        px = [polygon_vertices[i][0] for i in xrange(len(polygon_vertices))]
        py = [polygon_vertices[i][2] for i in xrange(len(polygon_vertices))]
        m.plot(px,py,linewidth=0.5,zorder=3,color='black')
    
    plt.savefig('world2.png',dpi=100)
    

    But this only works when using white background for the continents. If I change color to 'gray' in the following line, we see that other rivers and lakes are not filled with the same color as the continents are. (Also playing with area_thresh will not remove those rivers that are connected to ocean.)

    m.fillcontinents(color='gray',lake_color='white',zorder=2)
    

    world3

    The version with white background is adequate for further color-plotting all kind of land information over the continents, but a more elaborate solution would be needed, if one wants to retain the gray background for continents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a plot(x,y) is there any way to plot a line/curve/function that would split
If there is a way to Upload file using rest via stream would there
I would know if there is a way to know if an element of
Is there a way to get the columns that a SQL query would return
I would like to ask is there any way to achieve this functionality: I
Is there any way to have a default MessageBox.Show() caption? Let says I would
Is there a way to integrate CodeIgniter with phpBB3? I would like to use
I have trouble finding way to correctly refactor this code so that there would
I would like to print scrollable div as WYSWYG. Is there a way?
I'm new to PowerBuilder 12, and would like to know is there any way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.