Finding minimum from ListPlot












2












$begingroup$


I have Table with 10000 elements in it and I plot a graphic using ListPlot.
enter image description here



I need find minimum in graph.
enter image description here



Here is a .txt file with data.



I tried to use



Min[Data[[All,1]]]


the result is 0., cuz it search the first point of x but I don't need the first one.










share|improve this question











$endgroup$












  • $begingroup$
    Data[[Ordering[Data[[All,2]],1][[1]],1]]?
    $endgroup$
    – Henrik Schumacher
    12 hours ago
















2












$begingroup$


I have Table with 10000 elements in it and I plot a graphic using ListPlot.
enter image description here



I need find minimum in graph.
enter image description here



Here is a .txt file with data.



I tried to use



Min[Data[[All,1]]]


the result is 0., cuz it search the first point of x but I don't need the first one.










share|improve this question











$endgroup$












  • $begingroup$
    Data[[Ordering[Data[[All,2]],1][[1]],1]]?
    $endgroup$
    – Henrik Schumacher
    12 hours ago














2












2








2





$begingroup$


I have Table with 10000 elements in it and I plot a graphic using ListPlot.
enter image description here



I need find minimum in graph.
enter image description here



Here is a .txt file with data.



I tried to use



Min[Data[[All,1]]]


the result is 0., cuz it search the first point of x but I don't need the first one.










share|improve this question











$endgroup$




I have Table with 10000 elements in it and I plot a graphic using ListPlot.
enter image description here



I need find minimum in graph.
enter image description here



Here is a .txt file with data.



I tried to use



Min[Data[[All,1]]]


the result is 0., cuz it search the first point of x but I don't need the first one.







plotting list-manipulation mathematical-optimization peak-detection






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 14 mins ago









Community

1




1










asked 12 hours ago









JohnJohn

32016




32016












  • $begingroup$
    Data[[Ordering[Data[[All,2]],1][[1]],1]]?
    $endgroup$
    – Henrik Schumacher
    12 hours ago


















  • $begingroup$
    Data[[Ordering[Data[[All,2]],1][[1]],1]]?
    $endgroup$
    – Henrik Schumacher
    12 hours ago
















$begingroup$
Data[[Ordering[Data[[All,2]],1][[1]],1]]?
$endgroup$
– Henrik Schumacher
12 hours ago




$begingroup$
Data[[Ordering[Data[[All,2]],1][[1]],1]]?
$endgroup$
– Henrik Schumacher
12 hours ago










3 Answers
3






active

oldest

votes


















4












$begingroup$

This is how I would go about it:



minIndex = data[[All, 2]] // MinDetect // PositionIndex;


Now all the positions of the minima were collected in an Association and given the key 1. We now want to split the list of minima positions into sublists that are "connected", e.g. where each position is separated by a distance of 1. From these sublists we only need the first and the last positions (the "corners"):



minPositions = minIndex[1] // RightComposition[
Split[#, #1 == #2 - 1 &] & (* distance could be made more "soft" of course *)
, Part[#, All, {1, -1}] &
, Flatten
]



{1, 276, 1167, 2844}




We now Extract the data points for these positions dropping the first, which you do not need as you said:



minPoints = Extract[data, List /@ minPositions] // Drop[#, 1] &



{{0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




Finally:



ListPlot[ data, Epilog -> {Red, PointSize -> Large, Point@minPoints }, ImageSize -> Large ]


ListPlot of data with minima






share|improve this answer









$endgroup$





















    4












    $begingroup$

    lp = ListLinePlot[data, 
    MeshFunctions -> {#2 &},
    MeshStyle -> Directive[Red, PointSize[Large]],
    Mesh -> {{Min[data[[All, 2]]]}},
    AxesOrigin -> {0, -.01}]


    enter image description here



    To extract the data elements:



    Cases[Normal @ lp, Point[x_] :> x, All]



    {{0., 0.}, {0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




    If you want to remove the first point:



    lp /. Point[x_] :> Point[Rest @ x]


    enter image description here






    share|improve this answer











    $endgroup$





















      3












      $begingroup$

      This should do:



      MinimalBy[Data, Last]


      If you have runs of minimal elements and only want the first and last one: assuming that the grid spacing is 0.001 and inserting 10% of tolerance,



      Split[MinimalBy[Data, Last], #2[[1]]-#1[[1]] <= 0.0011 &][[All, {1,-1}]]


      maybe combined with Flatten to make into a single list of points.






      share|improve this answer











      $endgroup$













        Your Answer





        StackExchange.ifUsing("editor", function () {
        return StackExchange.using("mathjaxEditing", function () {
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
        });
        });
        }, "mathjax-editing");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "387"
        };
        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: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        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%2fmathematica.stackexchange.com%2fquestions%2f191251%2ffinding-minimum-from-listplot%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4












        $begingroup$

        This is how I would go about it:



        minIndex = data[[All, 2]] // MinDetect // PositionIndex;


        Now all the positions of the minima were collected in an Association and given the key 1. We now want to split the list of minima positions into sublists that are "connected", e.g. where each position is separated by a distance of 1. From these sublists we only need the first and the last positions (the "corners"):



        minPositions = minIndex[1] // RightComposition[
        Split[#, #1 == #2 - 1 &] & (* distance could be made more "soft" of course *)
        , Part[#, All, {1, -1}] &
        , Flatten
        ]



        {1, 276, 1167, 2844}




        We now Extract the data points for these positions dropping the first, which you do not need as you said:



        minPoints = Extract[data, List /@ minPositions] // Drop[#, 1] &



        {{0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




        Finally:



        ListPlot[ data, Epilog -> {Red, PointSize -> Large, Point@minPoints }, ImageSize -> Large ]


        ListPlot of data with minima






        share|improve this answer









        $endgroup$


















          4












          $begingroup$

          This is how I would go about it:



          minIndex = data[[All, 2]] // MinDetect // PositionIndex;


          Now all the positions of the minima were collected in an Association and given the key 1. We now want to split the list of minima positions into sublists that are "connected", e.g. where each position is separated by a distance of 1. From these sublists we only need the first and the last positions (the "corners"):



          minPositions = minIndex[1] // RightComposition[
          Split[#, #1 == #2 - 1 &] & (* distance could be made more "soft" of course *)
          , Part[#, All, {1, -1}] &
          , Flatten
          ]



          {1, 276, 1167, 2844}




          We now Extract the data points for these positions dropping the first, which you do not need as you said:



          minPoints = Extract[data, List /@ minPositions] // Drop[#, 1] &



          {{0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




          Finally:



          ListPlot[ data, Epilog -> {Red, PointSize -> Large, Point@minPoints }, ImageSize -> Large ]


          ListPlot of data with minima






          share|improve this answer









          $endgroup$
















            4












            4








            4





            $begingroup$

            This is how I would go about it:



            minIndex = data[[All, 2]] // MinDetect // PositionIndex;


            Now all the positions of the minima were collected in an Association and given the key 1. We now want to split the list of minima positions into sublists that are "connected", e.g. where each position is separated by a distance of 1. From these sublists we only need the first and the last positions (the "corners"):



            minPositions = minIndex[1] // RightComposition[
            Split[#, #1 == #2 - 1 &] & (* distance could be made more "soft" of course *)
            , Part[#, All, {1, -1}] &
            , Flatten
            ]



            {1, 276, 1167, 2844}




            We now Extract the data points for these positions dropping the first, which you do not need as you said:



            minPoints = Extract[data, List /@ minPositions] // Drop[#, 1] &



            {{0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




            Finally:



            ListPlot[ data, Epilog -> {Red, PointSize -> Large, Point@minPoints }, ImageSize -> Large ]


            ListPlot of data with minima






            share|improve this answer









            $endgroup$



            This is how I would go about it:



            minIndex = data[[All, 2]] // MinDetect // PositionIndex;


            Now all the positions of the minima were collected in an Association and given the key 1. We now want to split the list of minima positions into sublists that are "connected", e.g. where each position is separated by a distance of 1. From these sublists we only need the first and the last positions (the "corners"):



            minPositions = minIndex[1] // RightComposition[
            Split[#, #1 == #2 - 1 &] & (* distance could be made more "soft" of course *)
            , Part[#, All, {1, -1}] &
            , Flatten
            ]



            {1, 276, 1167, 2844}




            We now Extract the data points for these positions dropping the first, which you do not need as you said:



            minPoints = Extract[data, List /@ minPositions] // Drop[#, 1] &



            {{0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




            Finally:



            ListPlot[ data, Epilog -> {Red, PointSize -> Large, Point@minPoints }, ImageSize -> Large ]


            ListPlot of data with minima







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 11 hours ago









            gwrgwr

            8,42322761




            8,42322761























                4












                $begingroup$

                lp = ListLinePlot[data, 
                MeshFunctions -> {#2 &},
                MeshStyle -> Directive[Red, PointSize[Large]],
                Mesh -> {{Min[data[[All, 2]]]}},
                AxesOrigin -> {0, -.01}]


                enter image description here



                To extract the data elements:



                Cases[Normal @ lp, Point[x_] :> x, All]



                {{0., 0.}, {0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




                If you want to remove the first point:



                lp /. Point[x_] :> Point[Rest @ x]


                enter image description here






                share|improve this answer











                $endgroup$


















                  4












                  $begingroup$

                  lp = ListLinePlot[data, 
                  MeshFunctions -> {#2 &},
                  MeshStyle -> Directive[Red, PointSize[Large]],
                  Mesh -> {{Min[data[[All, 2]]]}},
                  AxesOrigin -> {0, -.01}]


                  enter image description here



                  To extract the data elements:



                  Cases[Normal @ lp, Point[x_] :> x, All]



                  {{0., 0.}, {0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




                  If you want to remove the first point:



                  lp /. Point[x_] :> Point[Rest @ x]


                  enter image description here






                  share|improve this answer











                  $endgroup$
















                    4












                    4








                    4





                    $begingroup$

                    lp = ListLinePlot[data, 
                    MeshFunctions -> {#2 &},
                    MeshStyle -> Directive[Red, PointSize[Large]],
                    Mesh -> {{Min[data[[All, 2]]]}},
                    AxesOrigin -> {0, -.01}]


                    enter image description here



                    To extract the data elements:



                    Cases[Normal @ lp, Point[x_] :> x, All]



                    {{0., 0.}, {0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




                    If you want to remove the first point:



                    lp /. Point[x_] :> Point[Rest @ x]


                    enter image description here






                    share|improve this answer











                    $endgroup$



                    lp = ListLinePlot[data, 
                    MeshFunctions -> {#2 &},
                    MeshStyle -> Directive[Red, PointSize[Large]],
                    Mesh -> {{Min[data[[All, 2]]]}},
                    AxesOrigin -> {0, -.01}]


                    enter image description here



                    To extract the data elements:



                    Cases[Normal @ lp, Point[x_] :> x, All]



                    {{0., 0.}, {0.275, 0.}, {1.166, 0.}, {2.843, 0.}}




                    If you want to remove the first point:



                    lp /. Point[x_] :> Point[Rest @ x]


                    enter image description here







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 9 hours ago

























                    answered 10 hours ago









                    kglrkglr

                    183k10201416




                    183k10201416























                        3












                        $begingroup$

                        This should do:



                        MinimalBy[Data, Last]


                        If you have runs of minimal elements and only want the first and last one: assuming that the grid spacing is 0.001 and inserting 10% of tolerance,



                        Split[MinimalBy[Data, Last], #2[[1]]-#1[[1]] <= 0.0011 &][[All, {1,-1}]]


                        maybe combined with Flatten to make into a single list of points.






                        share|improve this answer











                        $endgroup$


















                          3












                          $begingroup$

                          This should do:



                          MinimalBy[Data, Last]


                          If you have runs of minimal elements and only want the first and last one: assuming that the grid spacing is 0.001 and inserting 10% of tolerance,



                          Split[MinimalBy[Data, Last], #2[[1]]-#1[[1]] <= 0.0011 &][[All, {1,-1}]]


                          maybe combined with Flatten to make into a single list of points.






                          share|improve this answer











                          $endgroup$
















                            3












                            3








                            3





                            $begingroup$

                            This should do:



                            MinimalBy[Data, Last]


                            If you have runs of minimal elements and only want the first and last one: assuming that the grid spacing is 0.001 and inserting 10% of tolerance,



                            Split[MinimalBy[Data, Last], #2[[1]]-#1[[1]] <= 0.0011 &][[All, {1,-1}]]


                            maybe combined with Flatten to make into a single list of points.






                            share|improve this answer











                            $endgroup$



                            This should do:



                            MinimalBy[Data, Last]


                            If you have runs of minimal elements and only want the first and last one: assuming that the grid spacing is 0.001 and inserting 10% of tolerance,



                            Split[MinimalBy[Data, Last], #2[[1]]-#1[[1]] <= 0.0011 &][[All, {1,-1}]]


                            maybe combined with Flatten to make into a single list of points.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 9 hours ago

























                            answered 10 hours ago









                            RomanRoman

                            1,012511




                            1,012511






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Mathematica Stack Exchange!


                                • 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.


                                Use MathJax to format equations. MathJax reference.


                                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%2fmathematica.stackexchange.com%2fquestions%2f191251%2ffinding-minimum-from-listplot%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

                                404 Error Contact Form 7 ajax form submitting

                                How to know if a Active Directory user can login interactively

                                TypeError: fit_transform() missing 1 required positional argument: 'X'