MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

  • Python
  • numpy

numpy

NumPy is a general-purpose array-processing package designed to efficiently manipulate large multi-dimensional arrays of arbitrary records without sacrificing too much speed for small multi-dimensional arrays.

Sample histogram

From http://bespokeblog.wordpress.com/2011/07/11/basic-data-plotting-with-matplotlib-part-3-histograms/

Toggle line numbers
   1 import matplotlib.pyplot as plt
   2 from numpy.random import normal
   3 gaussian_numbers = normal(size=1000)
   4 plt.hist(gaussian_numbers)
   5 plt.title("Gaussian Histogram")
   6 plt.xlabel("Value")
   7 plt.ylabel("Frequency")
   8 plt.show()

SlackBuilds

numpy

Toggle line numbers
   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/development/numpy.tar.gz
   4 tar xvzf numpy.tar.gz
   5 cd numpy
   6 wget http://freefr.dl.sourceforge.net/project/numpy/NumPy/1.6.2/numpy-1.6.2.tar.gz
   7 ./numpy.SlackBuild
   8 installpkg  /tmp/numpy-1.6.2-i486-1_SBo.tgz

Package 32 bit: numpy-1.6.2-i486-1_SBo.tgz

Package 64 bit: numpy-1.6.2-x86_64-1_SBo.tgz

pytz

Toggle line numbers
   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/python/pytz.tar.gz
   4 tar xvzf pytz.tar.gz
   5 cd pytz
   6 wget https://launchpad.net/pytz/main/2012h/+download/pytz-2012h.tar.bz2
   7 ./pytz.SlackBuild
   8 installpkg /tmp/pytz-2012h-i486-1_SBo.tgz 

Package 32 bit: pytz-2012h-i486-1_SBo.tgz

Package 64 bit: pytz-2012h-x86_64-1_SBo.tgz

python-dateutil

Toggle line numbers
   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/python/python-dateutil.tar.gz
   4 tar xvzf python-dateutil.tar.gz
   5 cd python-dateutil
   6 wget http://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz
   7 ./python-dateutil.SlackBuild
   8 installpkg /tmp/python-dateutil-2.1-i486-1_SBo.tgz 

Package 32 bit: python-dateutil-2.1-i486-1_SBo.tgz

Package 64 bit: python-dateutil-2.1-x86_64-1_SBo.tgz

six

Toggle line numbers
   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/python/six.tar.gz
   4 tar xvzf six.tar.gz
   5 cd six
   6 wget http://pypi.python.org/packages/source/s/six/six-1.4.1.tar.gz
   7 ./six.SlackBuild
   8 installpkg  /tmp/six-1.4.1-i486-1_SBo.tgz 

Package 32 bit: six-1.3.0-i486-1_SBo.tgz

Package 64 bit: six-1.4.1-x86_64-1_SBo.tgz

pysetuptools

Toggle line numbers
   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/python/pysetuptools.tar.gz
   4 tar xvzf pysetuptools.tar.gz
   5 cd pysetuptools
   6 wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.9.8.tar.gz
   7 ./pysetuptools.SlackBuild
   8 installpkg  /tmp/pysetuptools-0.9.8-i486-1_SBo.tgz

Package 32 bit: pysetuptools-0.8-i486-1_SBo.tgz

Package 64 bit: pysetuptools-0.9.8-x86_64-1_SBo.tgz

matplotlib

Toggle line numbers
   1 su
   2 cd /tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/libraries/matplotlib.tar.gz
   4 tar xvzf matplotlib.tar.gz
   5 cd matplotlib
   6 wget http://downloads.sourceforge.net/matplotlib/matplotlib-1.1.1.tar.gz
   7 ./matplotlib.SlackBuild
   8 installpkg /tmp/matplotlib-1.1.1-i486-1_SBo.tgz

Package 32 bit: matplotlib-1.1.1-i486-1_SBo.tgz

Package 64 bit: matplotlib-1.1.1-x86_64-1_SBo.tgz

In windows

  • pip install numpy
  • pip install matplotlib

Simple plot

Toggle line numbers
   1 python3 -m venv plotEnv
   2 source plotEnv/bin/activate
   3 pip install --upgrade pip
   4 pip install numpy matplotlib pyqt5

simple_plot.py

Toggle line numbers
   1 # python3 simple_plot.py
   2 import matplotlib.pyplot as plt
   3 import numpy as np
   4 # Data for plotting
   5 start=0.0
   6 end=2.0
   7 step=0.01
   8 x_axis = np.arange(start, end, step) # <class 'numpy.ndarray'>
   9 y_axis = 1 + np.sin(2 * np.pi * x_axis) # <class 'numpy.ndarray'>
  10 image, window = plt.subplots()
  11 window.plot(x_axis, y_axis)
  12 window.set(xlabel='x', ylabel='sin(2*pi*x)',
  13        title='Sin wave from 0 to 2')
  14 window.grid()
  15 image.savefig("test.png")
  16 plt.show()

test_chart.py

Toggle line numbers
   1 # python3 test_chart.py
   2 import matplotlib.pyplot as plt
   3 import numpy as np
   4 x = np.array(['a', 'b', 'c'])
   5 y = np.array([1, 2, 3])
   6 image, window = plt.subplots()
   7 window.set(xlabel='x', ylabel='y',
   8        title='Test chart')
   9 window.grid()
  10 window.plot(x,y)
  11 plt.show()
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01