import matplotlib.pyplot as plt import numpy as np x = np.linspace(-0.5, 2.5, 301) # 2.5-(-0.5)=3; 3k+1 points; k = 100 here #print (x) # x is a numpy array which has 301 elements fig, ax = plt.subplots() # create a single figure and axes ax.spines['top'].set_visible(False) # do not show top spine ax.spines['right'].set_visible(False) # do not show right spine ax.spines['bottom'].set_position(('zero')) # set position of x spine to y = 0 ax.spines['left'].set_position(('zero')) # set position of y spine to x = 0 ax.set_xticks([-0.5,0.5,1.0,1.5,2.0,2.5]) # do not show 0.0 for x axis ax.set_yticks([-1.0,-0.5,0.5,1.0]) # do not show 0.0 for y axis ax.set_xticks(np.arange(-0.6,2.7,0.1), minor=True) # minor ticks ax.set_yticks(np.arange(-1.1,1.5,0.1), minor=True) # minor ticks ax.plot(x, x*x-2*x, label="$x^2-2x$") ax.legend(bbox_to_anchor=(0.5, 0.8), loc='center', borderaxespad=0, fontsize=10) fig.savefig("subplots.svg") # "subplots.pdf"