Line and dot plots

Line plot

We start with a simple line plot


In [18]:
import numpy as np
import matplotlib.pyplot as plt
# prepare data
x = np.arange(0,100)
y = (0.5-x)**2 + 2*x**2

# plot
plt.plot(x, y, color="forestgreen", label="legned")
plt.title('Title')
plt.legend()
plt.xlabel('x-axis')
plt.xlim(0,50)
plt.ylabel('y-axis')
plt.ylim(0,5000)
plt.show()
plt.close()


We want to add some error bars


In [33]:
import numpy as np
import matplotlib.pyplot as plt
# prepare data
x = np.arange(0,100)
y = (0.5-x)**2 + 2*x**2
yerr = np.log(y)*25

# plot
plt.plot(x, y, color="forestgreen", label="legned")
plt.title('Title')
plt.legend()
plt.xlabel('x-axis')
plt.xlim(0,50)
plt.ylabel('y-axis')
plt.ylim(0,5000)
plt.plot(x, y, '.', color="black")
plt.errorbar(x, y, yerr=yerr, fmt="none", ecolor="black")
plt.show()
plt.close()



In [ ]:


In [ ]: