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

The Archive Base Latest Questions

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

Does anyone know how to convert matplotlib data units into normalized units? The reason

  • 0

Does anyone know how to convert matplotlib data units into normalized units?

The reason that I need it is that I need to create a subplot on top of another plot.
And the default syntax:

plt.axes([0.1,0.1,0.3,0.3])

requires normalized coordinates, but I want to use the data coordinates:

For example this code:

  plt.plot([0,2],[2,4]);
  plt.axes([0.3,.3,0.4,.4])

produces this:

enter image description here
But I’d like to be able to define the location of the subplot using the data coordinates of it
, something like [0.7,2.5,1.7,3.5]. I’ve tried to fiddle with axes.transData, axes.get_transform() and the like but didn’t succeed to find the right function to do the job

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

    Here’s one way to do it:

    inner axes printed at 0.5, 2.5, 1.0, 0.3 (in outer axes coords)

    inner axes printed at 0.5, 2.5, 1.0, 0.3 (in outer axes coords)

    You basically need two transformations — one from src-coords to display, and one from display to dest-coord. From the docs there seems to be no direct way:
    http://matplotlib.org/users/transforms_tutorial.html

    bb_data = Bbox.from_bounds(0.5, 2.5, 1.0, 0.3)
    disp_coords = ax.transData.transform(bb_data)
    fig_coords = fig.transFigure.inverted().transform(disp_coords)
    

    ax and fig both carry transformer with them — to display-coords!
    If you call inverted on them, you get an transformer for the inverse direction.

    Here’s the full code for the above example:

    import matplotlib.pyplot as plt
    from matplotlib.transforms import Bbox
    
    plt.plot([0,2], [2,4])
    fig = plt.gcf()
    ax = plt.gca()
    
    bb_data = Bbox.from_bounds(0.5, 2.5, 1.0, 0.3)
    disp_coords = ax.transData.transform(bb_data)
    fig_coords = fig.transFigure.inverted().transform(disp_coords)
    
    fig.add_axes(Bbox(fig_coords))
    
    plt.show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a library or something that will convert an NSDate into
Does anyone know how to convert a string that represents a color into a
Does anyone know how to convert the string value type -4,5 or 5,4 into
Does anyone know of any (free) tools that will convert an old Delhi 5
Does anyone know a utility which could convert <style> blocks into the equivalent style
I was wondering does anyone know how to convert a string into a 2d
Does anyone know of a command-line tool that will convert both TTF and OTF
Does anyone know how to convert GSM audio into PCM WAV via C#? I
Does anyone know how to convert a string which contains json into a C#
Does anyone know how to convert language country codes like the ones below into

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.