Matplotlib
Matplot Library
Matplot Library Basic
Basic function
Import
import matplotlib.pyplot as plt
Figure
plt.figure
- Generate the table
Table
plt.xlabel('x')
plt.ylabel('y')
Text
plt.title('Sample Data with Initial Line')
plt.text(1, 7, 'Initial Slope of Line: ' + str(m0), fontsize=14)
Data
plt.xlim(0, 10)
plt.ylim(0, 10)
- data limit
Draw
plt.scatter(x, y, color='blue', s=20)
plt.plot(xplot, yplot, 'c--')
- scatter will draw dots to data on the table
- plot will draw a line.
- c means: color (crayon)
--
means: dot style
Jupyter
Basic setup
import torch
import matplotlib.pyplot as plt
%matplotlib inline # Only for Jupyter
plt.style.use('ggplot') # Graph Style
torch.manual_seed(0) # Set the random number generation seed to 0.
# Use it to reproduce the same results.
plt.rcParams["figure.figsize"] = (15, 8) # set the graph size
Leave a comment