Jump to content

Matplotlib: Difference between revisions

imported>Jesstess
No edit summary
imported>Jesstess
Line 112:
</ol>
 
<b>Read these short documents</b>:
* Pyplot tutorial (just this one section; stop before the next section "Controlling line properties"): http://matplotlib.sourceforge.net/users/pyplot_tutorial.html#pyplot-tutorial
* List of line options, including line style, and marker shapes and colors: http://wwwmatplotlib.thetechreposourceforge.comnet/main-articlesapi/469-how-to-change-line-properties-in-pyplot_api.html#matplotlib-python.pyplot.plot
 
<b>Check your understanding</b>:
Line 121:
 
 
=== 2. QueryPlotting the databaseworld population withover SELECTtime ===
 
<ol>
Try running the following queries from the sqlite prompt:
<li>
Run <code>python world_population.py</code>. This will pop up a window with a dot plot of the world population over the last 10,000 years.
</li>
<li>
Open <code>world_population.py</code>. Read through the code in this file.
 
In this example, we read our data from a file. Open the data file <code>world_population.txt</code> and examine the format of the file.
* <tt>SELECT * FROM category;</tt>
</li>
* <tt>SELECT NAME FROM category;</tt>
<li>
* <tt>SELECT * FROM clue;</tt>
Find the documentation on http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.plot for customizing the linewidth of plots. Then change the world population plot to use a magenta, down-triangle marker and a linewidth of 2.
* <tt>SELECT text, answer, value FROM clue;</tt>
</li>
* <tt>SELECT text, answer, value FROM clue LIMIT 10;</tt>
</ol>
 
<b>StepWord 2population resources</b>:
Explore the <code>category</code> and <code>clue</code> tables with your own SELECT queries.
 
<b>Check your understanding</b>:
* What does <code>*</code> mean in the above queries?
* What does the <code>LIMIT</code> SQL keyword do?
* Does case matter when making SQL queries?
 
<b>Step 2 resources</b>:
<ul>
<li>
File input and output: http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files.
Using SELECT: http://www.w3schools.com/sql/sql_select.asp
</li>
<li>
Splitting sprints into parts based on a delimiter: http://www.hacksparrow.com/python-split-string-method-and-examples.html
</li>
</ul>
 
<b>Check your understanding</b>:
* In <code>world_population.py</code>, what does <code>file("world_population.txt", "r").readlines()</code> return?
* In <code>world_population.py</code>, what does <code>point.split()</code> return?
 
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.