Scatter plot of 1-D bimodal data from sklearn make_blobs()How to plot 1-d data at given y-value with pylabHow to randomly select an item from a list?How do you read from stdin?Why can't Python parse this JSON data?How to put the legend out of the plotHow to put individual tags for a scatter plotWhy is reading lines from stdin much slower in C++ than Python?Save plot to image file instead of displaying it using Matplotlibmatplotlib scatter plot with different text at each data pointpyplot scatter plot marker sizeHow to make IPython notebook matplotlib plot inline

At what point in European history could a government build a printing press given a basic description?

What is the object moving across the ceiling in this stock footage?

What are the benefits of cryosleep?

How to make a crossed out leftrightarrow?

Four-in-a-line Puzzle

What is the 中 in ダウンロード中?

Does this degree 12 genus 1 curve have only one point over infinitely many finite fields?

Can a wire having 610-670 THz (frequency of blue light) A.C frequency supply, generate blue light?

I think I may have violated academic integrity last year - what should I do?

What do different value notes on the same line mean?

Is floating in space similar to falling under gravity?

Seed ship, unsexed person, cover has golden person attached to ship by umbilical cord

Is CD audio quality good enough for the final delivery of music?

Why is this Simple Puzzle impossible to solve?

Dictionary size reduces upon increasing one element

How do I align equations in three columns, justified right, center and left?

Plot twist where the antagonist wins

Why doesn't the Earth's acceleration towards the Moon accumulate to push the Earth off its orbit?

Is healing by fire possible?

Crossing US border with music files I'm legally allowed to possess

Is there a way to make it so the cursor is included when I prtscr key?

analysis of BJT PNP type - why they can use voltage divider?

How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?

How to capture more stars?



Scatter plot of 1-D bimodal data from sklearn make_blobs()


How to plot 1-d data at given y-value with pylabHow to randomly select an item from a list?How do you read from stdin?Why can't Python parse this JSON data?How to put the legend out of the plotHow to put individual tags for a scatter plotWhy is reading lines from stdin much slower in C++ than Python?Save plot to image file instead of displaying it using Matplotlibmatplotlib scatter plot with different text at each data pointpyplot scatter plot marker sizeHow to make IPython notebook matplotlib plot inline






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















sklearn make_blobs() function can be used to Generate isotropic Gaussian blobs for clustering.



I am trying to plot the data generated by make_blobs() function.



import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt

arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=1, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


this piece of code gives a normal distribution plot, which makes sense.



enter image description here



blobs, blob_labels = make_blobs(n_samples=1000, n_features=2, 
centers=2, random_state=1)

a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)


this piece of code gives a 2-clusters plot, which also makes sense.



enter image description here



I am wondering that is there a way to plot the data generated by make_blobs() function with params centers=2 n_features=1.



arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
centers=2, random_state=1)


I've tried plt.hist(), which gives another normal distribution plot.



I have no idea how to use plt.scatter() with the data.



I cannot image what the plot should look like.










share|improve this question






























    0















    sklearn make_blobs() function can be used to Generate isotropic Gaussian blobs for clustering.



    I am trying to plot the data generated by make_blobs() function.



    import numpy as np
    from sklearn.datasets import make_blobs
    import matplotlib.pyplot as plt

    arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
    centers=1, random_state=1)
    a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


    this piece of code gives a normal distribution plot, which makes sense.



    enter image description here



    blobs, blob_labels = make_blobs(n_samples=1000, n_features=2, 
    centers=2, random_state=1)

    a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)


    this piece of code gives a 2-clusters plot, which also makes sense.



    enter image description here



    I am wondering that is there a way to plot the data generated by make_blobs() function with params centers=2 n_features=1.



    arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
    centers=2, random_state=1)


    I've tried plt.hist(), which gives another normal distribution plot.



    I have no idea how to use plt.scatter() with the data.



    I cannot image what the plot should look like.










    share|improve this question


























      0












      0








      0








      sklearn make_blobs() function can be used to Generate isotropic Gaussian blobs for clustering.



      I am trying to plot the data generated by make_blobs() function.



      import numpy as np
      from sklearn.datasets import make_blobs
      import matplotlib.pyplot as plt

      arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
      centers=1, random_state=1)
      a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


      this piece of code gives a normal distribution plot, which makes sense.



      enter image description here



      blobs, blob_labels = make_blobs(n_samples=1000, n_features=2, 
      centers=2, random_state=1)

      a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)


      this piece of code gives a 2-clusters plot, which also makes sense.



      enter image description here



      I am wondering that is there a way to plot the data generated by make_blobs() function with params centers=2 n_features=1.



      arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
      centers=2, random_state=1)


      I've tried plt.hist(), which gives another normal distribution plot.



      I have no idea how to use plt.scatter() with the data.



      I cannot image what the plot should look like.










      share|improve this question
















      sklearn make_blobs() function can be used to Generate isotropic Gaussian blobs for clustering.



      I am trying to plot the data generated by make_blobs() function.



      import numpy as np
      from sklearn.datasets import make_blobs
      import matplotlib.pyplot as plt

      arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
      centers=1, random_state=1)
      a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


      this piece of code gives a normal distribution plot, which makes sense.



      enter image description here



      blobs, blob_labels = make_blobs(n_samples=1000, n_features=2, 
      centers=2, random_state=1)

      a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)


      this piece of code gives a 2-clusters plot, which also makes sense.



      enter image description here



      I am wondering that is there a way to plot the data generated by make_blobs() function with params centers=2 n_features=1.



      arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
      centers=2, random_state=1)


      I've tried plt.hist(), which gives another normal distribution plot.



      I have no idea how to use plt.scatter() with the data.



      I cannot image what the plot should look like.







      python matplotlib scikit-learn scatter-plot






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 10:52









      desertnaut

      22k84884




      22k84884










      asked Mar 24 at 7:10









      czlswsczlsws

      1677




      1677






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Your issue is somewhat unclear.




          I've tried plt.hist(), which gives another normal distribution plot.




          Well, not exactly; it gives a bimodal Gaussian mixture plot:



          arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
          centers=2, random_state=1)

          a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


          enter image description here



          as expected, since now we have centers=2.




          I have no idea how to use plt.scatter() with the data.




          By definition, a scatter plot needs 2D data; from the docs:




          A scatter plot of y vs x with varying marker size and/or color.




          while here, due to n_features=1, we actually have only x and no y.



          A 1D "scatter plot" is actually a line, and we can use plot to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:



          val = 0. # this is the value where you want the data to appear on the y-axis.
          a = plt.plot(arr, np.zeros_like(arr) + val, 'x')


          enter image description here



          where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.



          Want to use different colors and/or markers for each center?



          val = 0. # this is the value where you want the data to appear on the y-axis.
          plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
          plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
          plt.show()


          enter image description here



          where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000:



          enter image description here






          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%2f55321496%2fscatter-plot-of-1-d-bimodal-data-from-sklearn-make-blobs%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









            1














            Your issue is somewhat unclear.




            I've tried plt.hist(), which gives another normal distribution plot.




            Well, not exactly; it gives a bimodal Gaussian mixture plot:



            arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
            centers=2, random_state=1)

            a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


            enter image description here



            as expected, since now we have centers=2.




            I have no idea how to use plt.scatter() with the data.




            By definition, a scatter plot needs 2D data; from the docs:




            A scatter plot of y vs x with varying marker size and/or color.




            while here, due to n_features=1, we actually have only x and no y.



            A 1D "scatter plot" is actually a line, and we can use plot to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:



            val = 0. # this is the value where you want the data to appear on the y-axis.
            a = plt.plot(arr, np.zeros_like(arr) + val, 'x')


            enter image description here



            where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.



            Want to use different colors and/or markers for each center?



            val = 0. # this is the value where you want the data to appear on the y-axis.
            plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
            plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
            plt.show()


            enter image description here



            where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000:



            enter image description here






            share|improve this answer





























              1














              Your issue is somewhat unclear.




              I've tried plt.hist(), which gives another normal distribution plot.




              Well, not exactly; it gives a bimodal Gaussian mixture plot:



              arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
              centers=2, random_state=1)

              a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


              enter image description here



              as expected, since now we have centers=2.




              I have no idea how to use plt.scatter() with the data.




              By definition, a scatter plot needs 2D data; from the docs:




              A scatter plot of y vs x with varying marker size and/or color.




              while here, due to n_features=1, we actually have only x and no y.



              A 1D "scatter plot" is actually a line, and we can use plot to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:



              val = 0. # this is the value where you want the data to appear on the y-axis.
              a = plt.plot(arr, np.zeros_like(arr) + val, 'x')


              enter image description here



              where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.



              Want to use different colors and/or markers for each center?



              val = 0. # this is the value where you want the data to appear on the y-axis.
              plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
              plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
              plt.show()


              enter image description here



              where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000:



              enter image description here






              share|improve this answer



























                1












                1








                1







                Your issue is somewhat unclear.




                I've tried plt.hist(), which gives another normal distribution plot.




                Well, not exactly; it gives a bimodal Gaussian mixture plot:



                arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
                centers=2, random_state=1)

                a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


                enter image description here



                as expected, since now we have centers=2.




                I have no idea how to use plt.scatter() with the data.




                By definition, a scatter plot needs 2D data; from the docs:




                A scatter plot of y vs x with varying marker size and/or color.




                while here, due to n_features=1, we actually have only x and no y.



                A 1D "scatter plot" is actually a line, and we can use plot to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:



                val = 0. # this is the value where you want the data to appear on the y-axis.
                a = plt.plot(arr, np.zeros_like(arr) + val, 'x')


                enter image description here



                where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.



                Want to use different colors and/or markers for each center?



                val = 0. # this is the value where you want the data to appear on the y-axis.
                plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
                plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
                plt.show()


                enter image description here



                where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000:



                enter image description here






                share|improve this answer















                Your issue is somewhat unclear.




                I've tried plt.hist(), which gives another normal distribution plot.




                Well, not exactly; it gives a bimodal Gaussian mixture plot:



                arr, blob_labels = make_blobs(n_samples=1000, n_features=1, 
                centers=2, random_state=1)

                a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)


                enter image description here



                as expected, since now we have centers=2.




                I have no idea how to use plt.scatter() with the data.




                By definition, a scatter plot needs 2D data; from the docs:




                A scatter plot of y vs x with varying marker size and/or color.




                while here, due to n_features=1, we actually have only x and no y.



                A 1D "scatter plot" is actually a line, and we can use plot to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:



                val = 0. # this is the value where you want the data to appear on the y-axis.
                a = plt.plot(arr, np.zeros_like(arr) + val, 'x')


                enter image description here



                where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.



                Want to use different colors and/or markers for each center?



                val = 0. # this is the value where you want the data to appear on the y-axis.
                plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
                plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
                plt.show()


                enter image description here



                where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000:



                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 25 at 4:48

























                answered Mar 24 at 13:40









                desertnautdesertnaut

                22k84884




                22k84884





























                    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%2f55321496%2fscatter-plot-of-1-d-bimodal-data-from-sklearn-make-blobs%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권, 지리지 충청도 공주목 은진현