<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.christophchamp.com/index.php?action=history&amp;feed=atom&amp;title=Python%2Fmatplotlib</id>
		<title>Python/matplotlib - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.christophchamp.com/index.php?action=history&amp;feed=atom&amp;title=Python%2Fmatplotlib"/>
		<link rel="alternate" type="text/html" href="http://wiki.christophchamp.com/index.php?title=Python/matplotlib&amp;action=history"/>
		<updated>2026-04-30T16:25:45Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://wiki.christophchamp.com/index.php?title=Python/matplotlib&amp;diff=6907&amp;oldid=prev</id>
		<title>Christoph: /* External links */</title>
		<link rel="alternate" type="text/html" href="http://wiki.christophchamp.com/index.php?title=Python/matplotlib&amp;diff=6907&amp;oldid=prev"/>
				<updated>2017-03-30T23:53:42Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;External links&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:53, 30 March 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l119&quot; &gt;Line 119:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 119:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scripting languages]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scripting languages]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Machine Learning]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Christoph</name></author>	</entry>

	<entry>
		<id>http://wiki.christophchamp.com/index.php?title=Python/matplotlib&amp;diff=6897&amp;oldid=prev</id>
		<title>Christoph: Created page with &quot;'''matplotlib''' is a plotting library for the Python programming language and its numerical mathematics extension NumPy.  ==Examples==  &lt;pre&gt; import matplotl...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.christophchamp.com/index.php?title=Python/matplotlib&amp;diff=6897&amp;oldid=prev"/>
				<updated>2017-03-30T22:21:24Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;matplotlib&amp;#039;&amp;#039;&amp;#039; is a plotting library for the Python programming language and its numerical mathematics extension &lt;a href=&quot;/index.php?title=Python/NumPy&quot; title=&quot;Python/NumPy&quot;&gt;NumPy&lt;/a&gt;.  ==Examples==  &amp;lt;pre&amp;gt; import matplotl...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''matplotlib''' is a plotting library for the Python programming language and its numerical mathematics extension [[Python/NumPy|NumPy]].&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;Simple plot&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import matplotlib.pyplot as plt&lt;br /&gt;
import numpy as np&lt;br /&gt;
x = np.linspace(0, 10, 10) # start, end, num points in-between&lt;br /&gt;
y = np.sin(x)&lt;br /&gt;
plt.plot(x, y)&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
# Add labels&lt;br /&gt;
plt.plot(x, y)&lt;br /&gt;
plt.xlabel(&amp;quot;Time&amp;quot;)&lt;br /&gt;
plt.ylabel(&amp;quot;Some function of time&amp;quot;)&lt;br /&gt;
plt.title(&amp;quot;Example plot&amp;quot;)&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
# Increase number of points in-between&lt;br /&gt;
x = np.linspace(0, 10, 100)&lt;br /&gt;
y = np.sin(x)&lt;br /&gt;
plt.plot(x,y)&lt;br /&gt;
plt.show() # =&amp;gt; much smoother line&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Scatter plots&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
os.chdir('../linear_regression_class/')&lt;br /&gt;
import pandas as pd&lt;br /&gt;
A = pd.read_csv('data_1d.csv', header=None).as_matrix()&lt;br /&gt;
A.head()&lt;br /&gt;
A.info&lt;br /&gt;
A.shape&lt;br /&gt;
x = A[:,0]&lt;br /&gt;
y = A[:,1]&lt;br /&gt;
plt.scatter(x, y)&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
x_line = np.linspace(0, 100, 100)&lt;br /&gt;
y_line = 2*x_line + 1&lt;br /&gt;
plt.scatter(x, y)&lt;br /&gt;
plt.plot(x_line, y_line)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Histograms&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Using same data from above&lt;br /&gt;
plt.hist(x)&lt;br /&gt;
R = np.random.random(10000)&lt;br /&gt;
plt.hist(R)&lt;br /&gt;
plt.show()&lt;br /&gt;
plt.hist(R, bins=20)&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
# normally distributed&lt;br /&gt;
y_actual = 2*x + 1&lt;br /&gt;
residuals = y - y_actual&lt;br /&gt;
plt.hist(residuals)&lt;br /&gt;
plt.show()&lt;br /&gt;
# more-or-less a bell curve (with so few data points)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Plotting images&lt;br /&gt;
* An image is just a matrix of numbers&lt;br /&gt;
* A(i,j) represents the pixel intensity at coordinate (i,j)&lt;br /&gt;
* JPG or PNG are not matrices because they are compressed&lt;br /&gt;
* Decompress them to get back a matrix&lt;br /&gt;
* In this example, we will use the [[:wikipedia:MNIST_database|MNIST dataset]] (handwritten digits, 0-9)&lt;br /&gt;
** [https://www.kaggle.com/c/digit-recognizer Digit Recognizer] via Kaggle&lt;br /&gt;
** Download the &amp;quot;train.csv&amp;quot; file&lt;br /&gt;
* 28x28 = 784 pixels =&amp;gt; 784 columns in CSV file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import pandas as pd&lt;br /&gt;
&lt;br /&gt;
df = pd.read_csv(&amp;quot;train.csv&amp;quot;)&lt;br /&gt;
df.shape # =&amp;gt; (42000, 785)&lt;br /&gt;
&lt;br /&gt;
M = df.as_matrix()&lt;br /&gt;
&lt;br /&gt;
M[0,0] # =&amp;gt; digit &amp;quot;1&amp;quot;&lt;br /&gt;
im = M[0, 1:] # get 0th row and all columns except column 0&lt;br /&gt;
im.shape&lt;br /&gt;
im = im.reshape(28, 28)&lt;br /&gt;
im.shape&lt;br /&gt;
plt.imshow(im)&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
plt.imshow(im, cmap='gray')&lt;br /&gt;
plt.show()&lt;br /&gt;
plt.imshow(255 - im, cmap='gray')&lt;br /&gt;
plt.show()&lt;br /&gt;
&lt;br /&gt;
M[20,0] # =&amp;gt; digit &amp;quot;8&amp;quot;&lt;br /&gt;
im = M[20, 1:]&lt;br /&gt;
im.shape&lt;br /&gt;
im = im.reshape(28, 28)&lt;br /&gt;
plt.imshow(255 - im, cmap='gray')&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Python/NumPy|NumPy]]&lt;br /&gt;
* [[Python/SciPy|SciPy]]&lt;br /&gt;
* [[Python/pandas|pandas]]&lt;br /&gt;
* scikit-learn&lt;br /&gt;
* scikit-image&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://matplotlib.org/ Official website]&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting languages]]&lt;/div&gt;</summary>
		<author><name>Christoph</name></author>	</entry>

	</feed>