<jupyter_start><jupyter_text>教程：+ [Python 笔记：最全Matplotlib 入门教程](http://www.inimei.cn/archives/593.html)：前七章+ [NumPy  Matplotlib | 菜鸟教程](https://www.runoob.com/numpy/numpy-matplotlib.html)<jupyter_code>import matplotlib.pyplot as plt
plt.plot([1,2,3],[5,7,4])
plt.show()
x = [1,2,3]
y = [5,7,4]
 
x2 = [1,2,3]
y2 = [10,14,12]
plt.plot(x, y, label='First Line')
plt.plot(x2, y2, label='Second Line')
plt.xlabel('Plot Number')
plt.ylabel('Important var')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
plt.bar([1,3,5,7,9],[5,2,7,8,2], label="Example one")
 
plt.bar([2,4,6,8,10],[8,6,2,5,6], label="Example two", color='g')
plt.legend()
plt.xlabel('bar number')
plt.ylabel('bar height')
 
plt.title('Epic Graph\nAnother Line! Whoa')
 
plt.show()
population_ages = [22,55,62,45,21,22,34,42,42,4,99,102,110,120,121,122,130,111,115,112,80,75,65,54,44,43,42,48]
 
bins = [0,10,20,30,40,50,60,70,80,90,100,110,120,130]
 
plt.hist(population_ages, bins, histtype='bar', rwidth=0.5)
 
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.show()
x = [1,2,3,4,5,6,7,8]
y = [5,2,4,2,1,4,5,2]
 
plt.scatter(x,y, label='skitscat', color='k', s=25, marker="o")
 
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
days = [1,2,3,4,5]
 
sleeping = [7,8,6,11,7]
eating =   [2,3,4,3,2]
working =  [7,8,7,2,2]
playing =  [8,5,7,8,13]
plt.stackplot(days, sleeping,eating,working,playing, colors=['m','c','r','k'])
 
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.show()
days = [1,2,3,4,5]
 
sleeping = [7,8,6,11,7]
eating =   [2,3,4,3,2]
working =  [7,8,7,2,2]
playing =  [8,5,7,8,13]
 
 
plt.plot([],[],color='m', label='Sleeping', linewidth=5)
plt.plot([],[],color='c', label='Eating', linewidth=5)
plt.plot([],[],color='r', label='Working', linewidth=5)
plt.plot([],[],color='k', label='Playing', linewidth=5)
 
plt.stackplot(days, sleeping,eating,working,playing, colors=['m','c','r','k'])
 
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
slices = [7,2,2,13]
activities = ['sleeping','eating','working','playing']
cols = ['c','m','r','b']
 
plt.pie(slices,
        labels=activities,
        colors=cols,
        startangle=90,
        shadow= True,
        explode=(0,0.1,0,0),
        autopct='%1.1f%%')
 
plt.title('Interesting Graph\nCheck it out')
plt.show()
import csv
 
x = []
y = []
 
with open('example.txt','r') as csvfile:
    plots = csv.reader(csvfile, delimiter=',')
    for row in plots:
        x.append(int(row[0]))
        y.append(int(row[1]))
 
plt.plot(x,y, label='Loaded from file!')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
import numpy as np
 
x, y = np.loadtxt('example.txt', delimiter=',', unpack=True)
plt.plot(x,y, label='Loaded from file!')
 
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24109498680738786, 'fraction_numerical': 0.07849604221635884, 'mean_word_length': 5.665934065934066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '493516', 'license': 'MIT', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1357, 'n_words': 209, 'path': 'preparing/.ipynb_checkpoints/MatplotlibDemo-checkpoint.ipynb', 'repo_name': 'MikasaLee/Coursera-ML-AndrewNg-myNote', 'size': '3032'}