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 8306941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:25:51+00:00 2026-06-08T18:25:51+00:00

When I try to display LineCollections in both subplots, none are displayed. When I

  • 0

When I try to display LineCollections in both subplots, none are displayed. When I display it only in the first, it works. How can I get it to be displayed in both?

import numpy
import matplotlib.delaunay
from matplotlib import pyplot as plt
from matplotlib.collections import LineCollection

# Unique points
points = numpy.random.randint(0,2000, (1000, 2))
points = numpy.vstack([numpy.array(u) for u in set([tuple(p) for p in points])])

# Delaunay edges
centers, edges, tris, neighb = matplotlib.delaunay.delaunay(points[:,0], points[:,1])

# LineCollection of edges
lc_edges = LineCollection(points[edges])

# 1x2 subplots
fig,(ax) = plt.subplots(1, 2, figsize=(12,16))

ax1 = plt.subplot(211, aspect='equal', xlim=[points[:,0].min()- 100, points[:,0].max() + 100], ylim=[points[:,1].min() - 100, points[:,1].max() + 100])
plt.title("First plot")
plt.gca().add_collection(lc_edges)
plt.scatter(points[:,0], points[:,1])

ax2 = plt.subplot(212, aspect='equal', xlim=[points[:,0].min()- 100, points[:,0].max() + 100], ylim=[points[:,1].min() - 100, points[:,1].max() + 100])
plt.title("Second plot")
#plt.gca().add_collection(lc_edges)
plt.scatter(points[:,0], points[:,1])

fig.savefig('myfile.png', dpi=250)
plt.close()

EDIT:

The real question is “Can LineCollection objects be re-used?”

  • 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-08T18:25:52+00:00Added an answer on June 8, 2026 at 6:25 pm

    You can make a shadow copy of lc_edges by using copy module. Both the lc_edges2 and lc_edges will use the same path list, you can confirm it by: lc_edges._paths is lc_edges2._paths.

    import numpy
    import matplotlib.delaunay
    from matplotlib import pyplot as plt
    from matplotlib.collections import LineCollection
    import copy
    
    # Unique points
    points = numpy.random.randint(0,2000, (1000, 2))
    points = numpy.vstack([numpy.array(u) for u in set([tuple(p) for p in points])])
    
    # Delaunay edges
    centers, edges, tris, neighb = matplotlib.delaunay.delaunay(points[:,0], points[:,1])
    
    # LineCollection of edges
    lc_edges = LineCollection(points[edges])
    lc_edges2 = copy.copy(lc_edges)
    # 1x2 subplots
    fig,(ax) = plt.subplots(1, 2, figsize=(12,16))
    
    ax1 = plt.subplot(211, aspect='equal', xlim=[points[:,0].min()- 100, points[:,0].max() + 100], ylim=[points[:,1].min() - 100, points[:,1].max() + 100])
    plt.title("First plot")
    plt.gca().add_collection(lc_edges)
    plt.scatter(points[:,0], points[:,1])
    
    ax2 = plt.subplot(212, aspect='equal', xlim=[points[:,0].min()- 100, points[:,0].max() + 100], ylim=[points[:,1].min() - 100, points[:,1].max() + 100])
    plt.title("Second plot")
    
    plt.gca().add_collection(lc_edges2)
    plt.scatter(points[:,0], points[:,1])
    
    plt.show()
    

    The result looks like:

    LineCollection result

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

Sidebar

Related Questions

After query I try to display data. I can receive only data from 'field_1[]'.
I try to get one data column from a MS-Access table and display it
When I try to display the map I get this exception : Terminating app
Every time I try to display the category I get the name Array instead
I try to display an array item in dancer, here is the code: get
I try to display a Toast inside a AsyncTask. This first piece of code
When I try to display ImageIcon in JTable only description is rendered.The code is:
I'm try display data from column points , SELECT * from table ORDER by
I am using the following code to try and display in a time in
I am a total beginner to Objective C. Currently I try to display a

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.