반응형
In matlab, it is very easy to plot a graph. However, in python, you need to know which library do I have to import before plotting the graph.
In python, mathplotlib library supports plotting a graph like matlab.
Here is an example. Enjoy!
import numpy as np
import math
import matplotlib.pyplot as plt
x = range(0, 100) # x-axis (index)
y = np.zeros(100) # y-axis (value)
for i in range(0, 100):
y[i] = math.exp(-0.5*i)
plt.plot(x, y, label='test')
plt.xlabel('index')
plt.ylabel('exponential function')plt.legend()
plt.show()
'Python' 카테고리의 다른 글
How to resize an image : skimage library (0) | 2017.08.01 |
---|---|
How to show an image : skimage library (0) | 2017.07.21 |
[NYU depth] How to read NYU depth dataset in python (0) | 2017.07.20 |
How to write values in csv files (0) | 2017.07.18 |
How to read values from csv files (0) | 2017.07.18 |