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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:01:08+00:00 2026-05-31T21:01:08+00:00

I have a question. I have plotted a graph using Matplotlib like this: from

  • 0

I have a question.

I have plotted a graph using Matplotlib like this:

from matplotlib import pyplot
import numpy
from scipy.interpolate import spline

widths = numpy.array([0, 30, 60, 90, 120, 150, 180])
heights = numpy.array([26, 38.5, 59.5, 82.5, 120.5, 182.5, 319.5])

xnew = numpy.linspace(widths.min(),widths.max(),300)
heights_smooth = spline(widths,heights,xnew)

pyplot.plot(xnew,heights_smooth)
pyplot.show()

Now I want to query a height value using width value as an argument. I cannot seem to find how to do that. Please help! Thanks in advance!

  • 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-31T21:01:09+00:00Added an answer on May 31, 2026 at 9:01 pm

    plot() returns a useful object: [<matplotlib.lines.Line2D object at 0x38c9910>]
    From that we can get x- and y-axis values:

    import matplotlib.pyplot as plt, numpy as np
    ...
    line2d = plt.plot(xnew,heights_smooth)
    xvalues = line2d[0].get_xdata()
    yvalues = line2d[0].get_ydata()
    

    Then we can get the index of one of the width values:

    idx = np.where(xvalues==xvalues[-2]) # this is 179.3979933110368
    # idx is a tuple of array(s) containing index where value was found
    # in this case -> (array([298]),)
    

    And the corresponding height:

    yvalues[idx]
    # -> array([ 315.53469])
    

    To check we can use get_xydata():

    >>> xy = line2d[0].get_xydata()
    >>> xy[-2]
    array([ 179.39799331,  315.53469   ])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A quick question about a gnuplot. I have two graphs, ploted from file, like
I have question concerning a function I created. I would like to show the
I have several time series plotted with jfreechart. The graph also contains multiple annotations.
I have question regarding shared memory segmentation in c using POSIX system calls. Is
I have question with this same title here but now as I'll present in
I have question I'm developing small application to desktop in win Forms. I'm using
I have question about the beta Open Graph stuffs. The documentation I am looking
I have question regarding polymorphism about its assignment statement, for Example this is The
I have question regarding about finding subview using '.tags' in one UIView. for (UIView
I have just started using maven and have question. My pom.xml contains tag developer

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.