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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:13:24+00:00 2026-05-12T12:13:24+00:00

I have a follow up question to this question . Is it possible to

  • 0

I have a follow up question to this question.

Is it possible to streamline the figure generation by having multiple python scripts that work on different parts of the figure?

For example, if I have the following functions:

FunctionA: Draw a histogram of something
FunctionB: Draw a box with a text in it
FunctionC: Draw a plot of something C
FunctionD: Draw a plot of something D

How do I go about reusing the above functions in different scripts? If I wanted, for instance, to create a figure with a histogram with a plot of something C, I would somehow call FunctionA and FunctionC from my script. Or, if I wanted a figure with the two plots, I’d call FunctionC and FunctionD.

I’m not sure if I’m explaining myself clearly, but another way of asking this question is this: how do I pass a figure object to a function and then have the function draw something to the passed figure object and then return it back to the main script to add other things like the title or something?

  • 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-05-12T12:13:24+00:00Added an answer on May 12, 2026 at 12:13 pm

    Here you want to use the Artist objects, and pass them as needed to the functions:

    import numpy as np
    import matplotlib.pyplot as plt
    
    def myhist(ax, color):
        ax.hist(np.log(np.arange(1, 10, .1)), facecolor=color)
    
    def say_something(ax, words):
        t = ax.text(.2, 20., words)
        make_a_dim_yellow_bbox(t)
    
    def make_a_dim_yellow_bbox(txt):
        txt.set_bbox(dict(facecolor='yellow', alpha=.2))
    
    fig = plt.figure()
    ax0 = fig.add_subplot(1,2,1)
    ax1 = fig.add_subplot(1,2,2)
    
    myhist(ax0, 'blue')
    myhist(ax1, 'green')
    
    say_something(ax0, 'this is the blue plot')
    say_something(ax1, 'this is the green plot')
    
    plt.show()
    

    alt text

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

Sidebar

Related Questions

I have a follow up question to this one . Now that I have
This is a follow-up question to Combinatorics in Python I have a tree or
I have a follow-up question to this one . I created a new form,
This is somewhat of a follow-up question to this question . Suppose I have
Follow up to this question . I have the following code: string[] names =
this is a follow-up question of mine. Suppose now I have a URL :
This is a follow-up to my question from yesterday . I have Scott Meyers'
This is a follow up to this question , I'm trying to have the
This is a follow up to a previous question that I had before about
Follow-up to this question: Setting background-color of select options in JQuery I have 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.