IOException.de

Icon

Ausgewählter Nerdkram von Informatikstudenten der Uni Ulm

Histogramplot in Sage/Matplotlib

Wer Matlab mag wird Sage lieben, insbesondere wenn die Ausgangsdaten sowieso in Python vorliegen. Ein einfaches Histogram für Ganzzahlen lässt sich wie folgt realisieren:


from sage.all import *
import numpy
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab

def plot_hist(subplot,name,x_data,x_var,y_var,b_width):

  #create array
  n_array = numpy.array(x_data)

  #labels
  subplot.set_xlabel('variable '+x_var+' [min = '+str(n_array.min())+', max='+str(n_array.max())+' ]')
  subplot.set_ylabel(y_var)

  #create bins
  mmin = n_array.min()
  mmax = n_array.max()
  b = numpy.arange(mmin-(1.0/2),mmax+1+(1.0/2))

  #set ticks
  subplot.set_xticks(b)

  #hist
  n, bins, patches = subplot.hist(x_data,bins=b, rwidth=b_width)

  #title
  subplot.set_title(r'Histogram of '+x_var)

Benutzt wird das Ganze dann mittels:

f = matplotlib.pyplot.figure()
a = f.add_subplot(111)

plot_utils.plot_hist(a,'Decimals', [1,1,1,2,2,3,3,3,4,4,5,5,6,6,7,7],'decimal','# of decimals',0.8)

matplotlib.pyplot.savefig('plot.png')

ioexception.de

Benjamin Erb [] studiert seit 2006 Medieninformatik und interessiert sich insbesondere für Java, Web-Technologien, Ubiquitous Computing, Cloud Computing, verteilte Systeme und Informationsdesign.


Raimar Wagner studiert seit 2005 Informatik mit Anwendungsfach Medizin und interessiert sich für C++ stl, boost & Qt Programmierung, Scientific Visualization, Computer Vision und parallele Rechenkonzepte.


David Langer studiert seit 2006 Medieninformatik und interessiert sich für Web-Entwicklung, jQuery, Business Process Management und Java.


Sebastian Schimmel studiert seit 2006 Informatik mit Anwendungsfach Medizin und interessiert sich für hardwarenahe Aspekte, Robotik, webOs, C/C++ und UNIX/Linux.


Timo Müller studiert seit 2006 Medieninformatik. Er interessiert sich allen voran für Mobile and Ubiquitous Computing, systemnahe Enwticklung und verteilte Systeme, sowie Computer Vision.


Achim Strauß studiert seit 2006 Medieninformatik. Seine Interessen liegen in Themen der Mensch-Computer Interaktion sowie Webentwicklung und UNIX/Linux.


Tobias Schlecht studiert seit 2006 Medieninformatik und interessiert sich vor allem für Software Engineering, Model Driven Architecture, Requirements Engineering, Usability Engineering, Web-Technologien, UML2 und Java.


Fabian Groh studiert seit 2006 Medieninformatik. Seine Interessengebiete sind Computer Graphics, Computer Vision, Computational Photography sowie Ubiquitos Computing.


Matthias Matousek studiert seit 2007 Medieninformatik und interessiert sich besonders für Skriptsprachen, Echtzeitsysteme und Kommunikation.


Michael Müller [] studiert seit 2009 Medieninformatik. Er interessiert sich vor allem für Web-Technologien, Ubiquitous Computing, User-Interfaces, UNIX und Creative Coding.


Falco Nogatz [] studiert seit 2010 Informatik mit Anwendungsfach Mathematik. Er interessiert sich für Web-Technologien, Programmierparadigmen und theoretische Grundlagen.

Archiv

Februar 2012
M D M D F S S
« Dez    
 12345
6789101112
13141516171819
20212223242526
272829