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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:29:17+00:00 2026-06-15T01:29:17+00:00

I currently have code like the following: import os import numpy as np import

  • 0

I currently have code like the following:

import os
import numpy as np
import pylab 

import matplotlib.pyplot as plt
import matplotlib.cm as cm    
from matplotlib.patches import Polygon  
import numpy as np

...

# Read my image
img = matplotlib.image.imread(p_image)

# Render it, move the coordinates' origin to the upper left corner
plt.imshow(np.flipud(img), cmap=cm.Greys_r,origin='upper')

# Overlay a polygon
p = Polygon( zip(xs,ys), alpha=0.2)
plt.gca().add_artist(p)

# Save it to disk
plt.savefig(p_image_output)

How can I directly save this figure to disk without rendering it first on the screen? (notice that I would like the figure to keep the properties specified in the three arguments that I pass to imshow)

  • 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-15T01:29:18+00:00Added an answer on June 15, 2026 at 1:29 am

    Unless you are using ipython --pylab, the figure should only appear on screen if you do a show() or draw(). If you don’t want it to be shown on the screen, just make sure you are not doing any of those calls.

    Alternatively, you can use a non-interactive backend in matplotlib. For example, the Agg backend. Just make sure you have the following set in your ~/.matplotlib/matplotlibrc file:

    backend      : Agg
    

    Keep in mind that using this backend you’ll never see anything on screen. If you use ipython, you can keep the configuration file and have an interactive backend by calling --pylab with a specific backend. For example:

    ipython --pylab=qt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have the following code: import argparse parser = argparse.ArgumentParser(description='Adds a new modem
Currently I have code like the following (simplified somewhat). Eventually, I've added more and
Using dotnet 2.0. I currently have code like this : DataView dv = new
Currently, when I have code like this: series: {{ traffic_json|safe }}, Aptana flags the
I am currently working on a project where I have code that looks like
I have an Entity in Code First Entity framework that currently looks like this:
I currently have code that does the following: private final static ExecutorService pool =
I have a dead simple progress bar using something like the following: import sys
I'm using PyParsing with the following code, to parse date strings: from pyparsing import
I currently have code in objective C that can pull out an integer's most

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.