Plotting histograms, scatter plots in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dr. Colombes

    Plotting histograms, scatter plots in Python

    What is the easiest way to generate some plots and graphs in Python ?

    Specifically interested in simple histograms and scatter plots with
    circles and regression lines.

    Thanks for your suggestions.
  • Fernando Perez

    #2
    Re: Plotting histograms, scatter plots in Python

    Dr. Colombes wrote:
    [color=blue]
    > What is the easiest way to generate some plots and graphs in Python ?
    >
    > Specifically interested in simple histograms and scatter plots with
    > circles and regression lines.[/color]

    google('matplot lib')
    google('gnuplot .py')

    hth,

    f

    Comment

    • Peter Wilkinson

      #3
      Re: Plotting histograms, scatter plots in Python


      One module is Matplotlib, that seems to model the Matlab way of doing
      things .... its at sourceforge.

      Peter W.

      At 02:18 PM 8/6/2004, Dr. Colombes wrote:[color=blue]
      >What is the easiest way to generate some plots and graphs in Python ?
      >
      >Specifically interested in simple histograms and scatter plots with
      >circles and regression lines.
      >
      >Thanks for your suggestions.
      >--
      >http://mail.python.org/mailman/listinfo/python-list[/color]

      Comment

      • John Hunter

        #4
        Re: Plotting histograms, scatter plots in Python

        >>>>> "Colombes" == Colombes <DrColombes@yah oo.com> writes:

        Colombes> What is the easiest way to generate some plots and
        Colombes> graphs in Python ? Specifically interested in simple
        Colombes> histograms and scatter plots with circles and regression
        Colombes> lines.

        Here's a little example of a histogram and regression plot using
        matplotlib - looks easy enough to me! Output image at


        from matplotlib.matl ab import *

        x = randn(10000) # some gaussian noise

        subplot(211) # a subplot
        hist(x, 100) # make a histogram
        grid(True) # make an axes grid
        ylabel('histogr am')

        # now do the regression...
        x = arange(0.0, 2.0, 0.05)
        y = 2+ 3*x + 0.2*randn(len(x )) # y is a linear function of x + nse

        # the bestfit line from polyfit
        m,b = polyfit(x,y,1) # a line is 1st order polynomial...

        # plot the data with blue circles and the best fit with a thick
        # solid black line
        subplot(212)
        plot(x, y, 'bo', x, m*x+b, '-k', linewidth=2)
        ylabel('regress ion')
        grid(True)

        # save the image to hardcopy
        savefig('demo')
        show()

        Comment

        • Paramjit Oberoi

          #5
          Re: Plotting histograms, scatter plots in Python

          > What is the easiest way to generate some plots and graphs in Python ?

          Pychart:

          Comment

          • Colin J. Williams

            #6
            Re: Plotting histograms, scatter plots in Python



            Paramjit Oberoi wrote:[color=blue][color=green]
            >>What is the easiest way to generate some plots and graphs in Python ?[/color]
            >
            >
            > Pychart:
            > http://www.hpl.hp.com/personal/Yasushi_Saito/pychart/[/color]

            The charts look good, but the source code links fail.

            Colin W.

            Comment

            • Paramjit Oberoi

              #7
              Re: Plotting histograms, scatter plots in Python

              >> Pychart:[color=blue][color=green]
              >> http://www.hpl.hp.com/personal/Yasushi_Saito/pychart/[/color]
              >
              > The charts look good, but the source code links fail.[/color]

              I just tried downloading it, and they seem to work for me...

              Comment

              • Fernando Perez

                #8
                Re: Plotting histograms, scatter plots in Python

                Colin J. Williams wrote:
                [color=blue]
                >
                >
                > Paramjit Oberoi wrote:[color=green][color=darkred]
                >>>What is the easiest way to generate some plots and graphs in Python ?[/color]
                >>
                >>
                >> Pychart:
                >> http://www.hpl.hp.com/personal/Yasushi_Saito/pychart/[/color]
                >
                > The charts look good, but the source code links fail.[/color]

                I found it funny that the author makes a comment about poor PostScript quality
                in Gnuplot, touting his as an alternative. If the examples on that page are to
                be believed, that stuff looks like low-quality Excel-type business charts,
                while Gnuplot has been producing publication quality EPS for a loooong time
                (ask the many thousands of scientists using it since the early 90's).

                I'd say that matplotlib is the _real_ contender to gnuplot today, not that toy
                with horrible font scaling, no apparent real symbol/math support, ugly legend
                boxes...

                Best,

                f

                Comment

                • benzwt@yahoo.com.tw

                  #9
                  Re: Plotting histograms, scatter plots in Python

                  DrColombes@yaho o.com (Dr. Colombes) wrote in message news:<d1f3d1d3. 0408061018.137b 600f@posting.go ogle.com>...[color=blue]
                  > What is the easiest way to generate some plots and graphs in Python ?
                  >
                  > Specifically interested in simple histograms and scatter plots with
                  > circles and regression lines.
                  >
                  > Thanks for your suggestions.[/color]

                  For high quality scientific plot I suggest
                  ppgplot and plplot.

                  pgplot (original)


                  ppgplot (python module)


                  plplot
                  Homepage of the open source PLplot project

                  Comment

                  • Dr. Colombes

                    #10
                    Re: Plotting histograms, scatter plots in Python

                    John, Peter et al:

                    Thanks very much for your useful tips on MathPlotLib.

                    I've begun using MatPlotLib and I like it.

                    Others suggested GnuPlot, which I hope to try sometime in the
                    future.

                    Thanks all. This is a good example of very useful information
                    exchanged over an Internet newsgroup.

                    Dr. Colombes

                    John Hunter <jdhunter@ace.b sd.uchicago.edu > wrote in message news:<mailman.1 312.1091824333. 5135.python-list@python.org >...[color=blue][color=green][color=darkred]
                    > >>>>> "Colombes" == Colombes <DrColombes@yah oo.com> writes:[/color][/color]
                    >
                    > Colombes> What is the easiest way to generate some plots and
                    > Colombes> graphs in Python ? Specifically interested in simple
                    > Colombes> histograms and scatter plots with circles and regression
                    > Colombes> lines.
                    >
                    > Here's a little example of a histogram and regression plot using
                    > matplotlib - looks easy enough to me! Output image at
                    > http://nitace.bsd.uchicago.edu:8080/...share/demo.png
                    >
                    > from matplotlib.matl ab import *
                    >
                    > x = randn(10000) # some gaussian noise
                    >
                    > subplot(211) # a subplot
                    > hist(x, 100) # make a histogram
                    > grid(True) # make an axes grid
                    > ylabel('histogr am')
                    >
                    > # now do the regression...
                    > x = arange(0.0, 2.0, 0.05)
                    > y = 2+ 3*x + 0.2*randn(len(x )) # y is a linear function of x + nse
                    >
                    > # the bestfit line from polyfit
                    > m,b = polyfit(x,y,1) # a line is 1st order polynomial...
                    >
                    > # plot the data with blue circles and the best fit with a thick
                    > # solid black line
                    > subplot(212)
                    > plot(x, y, 'bo', x, m*x+b, '-k', linewidth=2)
                    > ylabel('regress ion')
                    > grid(True)
                    >
                    > # save the image to hardcopy
                    > savefig('demo')
                    > show()[/color]

                    Comment

                    Working...