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

  • Home
  • SEARCH
  • 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 9205383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:56:18+00:00 2026-06-17T23:56:18+00:00

I am using the matplotlib PatchCollection to hold a bunch of matplotlib.patches.Rectangles. But I

  • 0

I am using the matplotlib PatchCollection to hold a bunch of matplotlib.patches.Rectangles. But I want them to be invisible when first drawn (only turn visible when something else is clicked). This works fine when I was drawing the Rectangle’s straight to the canvas with add_artist, but I want to change this to using a PatchCollection. For some reason, when I create the PatchCollection and add it with add_collection, they are all visible.

self.plotFigure = Figure()
self.plotAxes = self.plotFigure.add_subplot(111)

self.selectionPatches = []
for node in self.nodeList:
    node.selectionRect = Rectangle((node.posX - node.radius*0.15 , node.posY - node.radius*0.15),
                                    node.radius*0.3,
                                    node.radius*0.3,
                                    linewidth = 0,
                                    facecolor = mpl.colors.ColorConverter.colors['k'],
                                    zorder = z,
                                    visible = False)
    self.selectionPatches.append(node.selectionRect)

self.p3 = PatchCollection(self.selectionPatches, match_original=True)
self.plotAxes.add_collection(self.p3)

If I iterate through self.selectionPatches and print out each Rectangle’s get_visible(), it returns false. But they are clearly visible when they get drawn. If anyone can help me see why this is happening, I would be very grateful.

  • 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-17T23:56:19+00:00Added an answer on June 17, 2026 at 11:56 pm

    When you create a PatchCollection it extracts a whole bunch of information from the objects you hand in (shape, location, styling(if you use match_original)), but does not keep the patch objects around for later reference (so it discards the per-patch visible). If you want all of the rectangles to be visible/invisible together you can do

    self.p3 = PatchCollection(self.selectionPatches, 
                              match_original=True, 
                              visible=False)
    

    other wise I think you will have to group them into the sets you want to appear together.

    Look at the __init__ function of PatchCollection(here) and the rest of the cascade up through Collection and Artist.

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

Sidebar

Related Questions

I want to get visualized statistics from my data in mongodb using matplotlib, but
I am creating some graphs using matplotlib, and I want to be able to
Hi probably quite a simple question but.. When plotting a graph using matplotlib.pyplot my
I want to plot a certain range of values within 2 arrays using matplotlib,
I want to make a daily profile plot: hour vs concentrations. I'm using matplotlib
I'm using matplotlib to draw some artists (a couple rectangles, specifically) on a graph.
I have some complex graphs made using matplotlib. Saving them to a pdf using
I have a bunch of points that I am trying to plot using matplotlib.
I am plotting using Matplotlib in Python. I want create plot with grid, and
I want to make a scatter plot using matplotlib. If I want to use

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.