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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:49:32+00:00 2026-05-25T01:49:32+00:00

I have multiple lines to be drawn on the same axes, and each of

  • 0

I have multiple lines to be drawn on the same axes, and each of them are dynamically updated (I use set_data), The issue being that i am not aware of the x and y limits of each of the lines. And axes.autoscale_view(True,True,True) / axes.set_autoscale_on(True) are not doing what they are supposed to. How do i auto scale my axes?

import matplotlib.pyplot as plt

fig = plt.figure()
axes = fig.add_subplot(111)

axes.set_autoscale_on(True)
axes.autoscale_view(True,True,True)

l1, = axes.plot([0,0.1,0.2],[1,1.1,1.2])
l2, = axes.plot([0,0.1,0.2],[-0.1,0,0.1])

#plt.show() #shows the auto scaled.

l2.set_data([0,0.1,0.2],[-1,-0.9,-0.8])

#axes.set_ylim([-2,2]) #this works, but i cannot afford to do this.  

plt.draw()
plt.show() #does not show auto scaled

I have referred to these already, this , this.
In all cases I have come across, the x,y limits are known. I have multiple lines on the axes and their ranges change, keeping track of the ymax for the entire data is not practical

A little bit of exploring got me to this,

xmin,xmax,ymin,ymax = matplotlib.figure.FigureImage.get_extent(FigureImage) 

But here again, i do not know how to access FigureImage from the Figure instance.

Using matplotlib 0.99.3

  • 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-25T01:49:33+00:00Added an answer on May 25, 2026 at 1:49 am

    From the matplotlib docs for autoscale_view:

    The data limits are not updated automatically when artist data are changed after the artist has been added to an Axes instance. In that case, use matplotlib.axes.Axes.relim() prior to calling autoscale_view.

    So, you’ll need to add two lines before your plt.draw() call after the set_data call:

    axes.relim()
    axes.autoscale_view(True,True,True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form element that contains multiple lines of inputs. Think of each
A UILabel's text is drawn in a CGRect(x,y,size,width). The label can have multiple lines
I have multiple line series in a chart. Chart lines are drawn first and
I have multiple lines of data all sharing the same Company id. Is there
I am trying to have a tooltip on multiple lines. how do i do
Is there a way to have a statement across multiple lines without the underscore
We have multiple MFC apps, which use CMutex( false, blah ), where blah allows
I have multiple classes that all derive from a base class, now some of
I'm trying to let a user draw lines on multiple UIView canvases that are
I have a program (a fractal) that draws lines in an interlaced order. Originally,

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.