Find y value for respective x from python plot (matplotlib)Calling a function of a module by using its name (a string)Finding the index of an item given a list containing it in PythonHow do I return multiple values from a function?Getting the class name of an instance?Convert bytes to a string?Hiding axis text in matplotlib plotsWhy is reading lines from stdin much slower in C++ than Python?Save plot to image file instead of displaying it using MatplotlibHow to make IPython notebook matplotlib plot inlineWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?

Does the Grothendieck group of finitely generated modules form a commutative ring where the multiplication structure is induced from tensor product?

How might boat designs change in order to allow them to be pulled by dragons?

Trace in the category of propositional statements

How to extract coefficients of a generating function like this one, using a computer?

What was the point of separating stdout and stderr?

To “Er” Is Human

"Best practices" for formulating MIPs

Are the Gray and Death Slaad's Bite and Claw attacks magical?

Cannot overlay, because ListPlot does not draw same X range despite the same PlotRange

Confusion in understanding the behavior of inductor in RL circuit with DC source

Simplify the code

GFCI versus circuit breaker

Searching for single buildings in QGIS

Replacing 5 gang light switches that have 3 of them daisy chained together

Are there advantages in writing by hand over typing out a story?

How can I change my buffer system for protein purification?

German idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)

What is the point of using the kunai?

What happened to the Apollo 1 rocket?

How come having a Deathly Hallow is not a big deal?

Does friction always oppose motion?

What caused the flashes in the video footage of Chernobyl?

What could a Medieval society do with excess animal blood?

How can solar sailed ships be protected from space debris?



Find y value for respective x from python plot (matplotlib)


Calling a function of a module by using its name (a string)Finding the index of an item given a list containing it in PythonHow do I return multiple values from a function?Getting the class name of an instance?Convert bytes to a string?Hiding axis text in matplotlib plotsWhy is reading lines from stdin much slower in C++ than Python?Save plot to image file instead of displaying it using MatplotlibHow to make IPython notebook matplotlib plot inlineWhy is “1000000000000000 in range(1000000000000001)” so fast in Python 3?













1















I'm trying to find the code to find the value of 'y' to a respective 'x' value by using a plotted line graph.
I've used matplotlib.pyplot to plot a graph.
The 'x' value for which I want the 'y' value is not a part of the x values array. Is there a way to find the respective 'y' value for the same?



If I have to find the value of Y for X = 0.75, how do I do that?



enter image description here










share|improve this question

















  • 1





    You could try fitting a linear regression on your first two data points, then use the slope and intercept from that to get the equation for the line between them. Then plug in the x-value you want to find the corresponding y-value.

    – HS-nebula
    Mar 25 at 17:32















1















I'm trying to find the code to find the value of 'y' to a respective 'x' value by using a plotted line graph.
I've used matplotlib.pyplot to plot a graph.
The 'x' value for which I want the 'y' value is not a part of the x values array. Is there a way to find the respective 'y' value for the same?



If I have to find the value of Y for X = 0.75, how do I do that?



enter image description here










share|improve this question

















  • 1





    You could try fitting a linear regression on your first two data points, then use the slope and intercept from that to get the equation for the line between them. Then plug in the x-value you want to find the corresponding y-value.

    – HS-nebula
    Mar 25 at 17:32













1












1








1








I'm trying to find the code to find the value of 'y' to a respective 'x' value by using a plotted line graph.
I've used matplotlib.pyplot to plot a graph.
The 'x' value for which I want the 'y' value is not a part of the x values array. Is there a way to find the respective 'y' value for the same?



If I have to find the value of Y for X = 0.75, how do I do that?



enter image description here










share|improve this question














I'm trying to find the code to find the value of 'y' to a respective 'x' value by using a plotted line graph.
I've used matplotlib.pyplot to plot a graph.
The 'x' value for which I want the 'y' value is not a part of the x values array. Is there a way to find the respective 'y' value for the same?



If I have to find the value of Y for X = 0.75, how do I do that?



enter image description here







python matplotlib






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 17:27









shellymshellym

1797 bronze badges




1797 bronze badges







  • 1





    You could try fitting a linear regression on your first two data points, then use the slope and intercept from that to get the equation for the line between them. Then plug in the x-value you want to find the corresponding y-value.

    – HS-nebula
    Mar 25 at 17:32












  • 1





    You could try fitting a linear regression on your first two data points, then use the slope and intercept from that to get the equation for the line between them. Then plug in the x-value you want to find the corresponding y-value.

    – HS-nebula
    Mar 25 at 17:32







1




1





You could try fitting a linear regression on your first two data points, then use the slope and intercept from that to get the equation for the line between them. Then plug in the x-value you want to find the corresponding y-value.

– HS-nebula
Mar 25 at 17:32





You could try fitting a linear regression on your first two data points, then use the slope and intercept from that to get the equation for the line between them. Then plug in the x-value you want to find the corresponding y-value.

– HS-nebula
Mar 25 at 17:32










1 Answer
1






active

oldest

votes


















3














We can use the interp function from numpy library.



import numpy as np
x = [0.01474926, 0.96923077, 1]
y = [1, 0.7875, 0]
np.interp(0.75, x,y)
0.8363082148652623





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343417%2ffind-y-value-for-respective-x-from-python-plot-matplotlib%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    We can use the interp function from numpy library.



    import numpy as np
    x = [0.01474926, 0.96923077, 1]
    y = [1, 0.7875, 0]
    np.interp(0.75, x,y)
    0.8363082148652623





    share|improve this answer



























      3














      We can use the interp function from numpy library.



      import numpy as np
      x = [0.01474926, 0.96923077, 1]
      y = [1, 0.7875, 0]
      np.interp(0.75, x,y)
      0.8363082148652623





      share|improve this answer

























        3












        3








        3







        We can use the interp function from numpy library.



        import numpy as np
        x = [0.01474926, 0.96923077, 1]
        y = [1, 0.7875, 0]
        np.interp(0.75, x,y)
        0.8363082148652623





        share|improve this answer













        We can use the interp function from numpy library.



        import numpy as np
        x = [0.01474926, 0.96923077, 1]
        y = [1, 0.7875, 0]
        np.interp(0.75, x,y)
        0.8363082148652623






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 17:33









        Siong Thye GohSiong Thye Goh

        2,2197 gold badges14 silver badges22 bronze badges




        2,2197 gold badges14 silver badges22 bronze badges
















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343417%2ffind-y-value-for-respective-x-from-python-plot-matplotlib%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현