
上QQ阅读APP看书,第一时间看更新
How it works...
- x = np.linspace(-50,50,500) creates 500 points with equal distance between them ranging from -50 to +50 for x axis co-ordinates.
- def Num_Format(x, pos) is a function to format large numeric numbers into $K or $M based on whether the number is in the thousand or the millions. FuncFormatter(Num_Format) is a matplotlib function that takes the user-defined function currency as an argument, and this FuncFormatter is then applied to the x or y axis on which numbers are to be formatted, using axs[0].yaxis.set_major_formatter(formatter).
- axs[0].plot(x, y**2) plots the graph on axes 0, using default settings for the x and y axes, so it displays a full range of data from the input.
- axs[1].plot(x, y**2) plots the same graph again on axis one.
- axs[1].set_xlim(-5,5) sets the data limit from -5 to +5 on the x axis, and axs[1].set_ylim(0,10000) sets the data limit from 0 to 10,000 on the y axis. These limits are set to the plot on axis one.
You should get the two plots as shown here: