<jupyter_start><jupyter_text>Chapter 1: Hello Plotting World!==___<jupyter_code>%matplotlib inline<jupyter_output><empty_output><jupyter_text>Using Jupyter notebook  Editing and running code<jupyter_code>def demo(n):
    for i in range(n):
        print(i)
demo(10)<jupyter_output>0
1
2
3
4
5
6
7
8
9<jupyter_text>Jotting down notes in Markdown mode Title: My first notebook== Header 1 Header 2- point 1- point 2This is IMPORTANTSo is **THIS** (Double click to edit, Shift+Enter to display) ___ Viewing Matplotlib plots<jupyter_code># Be sure to call this Jupyter notebook "cell magic" each time when opening a new notebook, 
# to display the matplotlib plots in output cells
%matplotlib inline<jupyter_output><empty_output><jupyter_text>___ Plotting our first graph  Loading data for plotting  Data structures  List<jupyter_code>evens = [2,4,6,8,10]
print(evens)
evens = list(range(2,102,2))
print(evens)<jupyter_output>[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]<jupyter_text>Numpy array<jupyter_code>import numpy as np
np.array(evens)
np.arange(2,102,2)<jupyter_output><empty_output><jupyter_text>Pandas dataframe<jupyter_code>import pandas as pd
df = pd.DataFrame(evens)
df.to_csv('evens.txt', sep='\t', header=False )<jupyter_output><empty_output><jupyter_text>___ Loading data from files  The basic Python way<jupyter_code>evens = []
with open('evens.txt') as f:
    for line in f.readlines():
        evens.append(int(line.split()[1]))
print(evens)
evens = [int(x.split()[1]) for x in open('evens.txt').readlines()]
print(evens)<jupyter_output>[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]<jupyter_text>The Numpy way<jupyter_code>import numpy as np
evens = np.loadtxt('evens.txt',delimiter='\t',usecols=1,dtype=np.int32)
print(evens)<jupyter_output>[  2   4   6   8  10  12  14  16  18  20  22  24  26  28  30  32  34  36
  38  40  42  44  46  48  50  52  54  56  58  60  62  64  66  68  70  72
  74  76  78  80  82  84  86  88  90  92  94  96  98 100]<jupyter_text>The pandas way<jupyter_code>import pandas as pd
evens = pd.read_csv('evens.txt',delimiter='\t',usecols=[1],header=None)
print(evens)<jupyter_output>1
0     2
1     4
2     6
3     8
4    10
5    12
6    14
7    16
8    18
9    20
10   22
11   24
12   26
13   28
14   30
15   32
16   34
17   36
18   38
19   40
20   42
21   44
22   46
23   48
24   50
25   52
26   54
27   56
28   58
29   60
30   62
31   64
32   66
33   68
34   70
35   72
36   74
37   76
38   78
39   80
40   82
41   84
42   86
43   88
44   90
45   92
46   94
47   96
48   98
49  100<jupyter_text>___ Importing the Matplotlib pyplot module<jupyter_code>import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>___ Plotting a curve Viewing the figure<jupyter_code>plt.plot(evens)
plt.show()
plt.plot(evens,evens**2)
plt.show()
plt.plot(evens,evens**2,label = 'x^2')
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>Saving the figure<jupyter_code>plt.plot(evens,evens**2,label = 'x^2')
plt.legend()
plt.savefig('output.png',dpi=300)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12261336515513127, 'fraction_numerical': 0.15692124105011934, 'mean_word_length': 3.952732644017725, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '648039', 'license': 'MIT', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1421, 'n_words': 433, 'path': 'Chapter01/Chapter 1-Hello Plotting World.ipynb', 'repo_name': 'cpepper/Matplotlib-2.x-By-Example', 'size': '3352'}