Lesson 07.3: 2D scattering plots with random number
隨機亂數作scatering plot
Example Code
- import sys
- if sys.version_info[0] < 3:
- from Tkinter import *
- else:
- from tkinter import *
- import os
- import numpy as np
- import matplotlib
- import matplotlib.pyplot as plt
- np.random.seed(1)
- plt.figure(1)
- plt.plot(10*np.random.randn(100), 10*np.random.randn(100), 'bo')
- plt.plot(10*np.random.randn(30), 10*np.random.randn(30), 'r.')
- plt.show()
Note and Comments
- import sys
- if sys.version_info[0] < 3:
- from Tkinter import *
- else:
- from tkinter import *
- import os
- import numpy as np
- import matplotlib
- import matplotlib.pyplot as plt
- np.random.seed(1)
- plt.figure(1)
- plt.plot(10*np.random.randn(100), 10*np.random.randn(100), 'bo')
- plt.plot(10*np.random.randn(30), 10*np.random.randn(30), 'r.')
- plt.show()
result