![]() Change the line colour and width using the c and lw keyword arguments in the ax.plot() call (see this page for all the colour and line options).Change the axis limits with ax.set_ylim() and ax.set_xlim().Set the axis labels with ax.set_ylabel() and ax.set_xlabel().The y-data was then created by taking the square of the x-data.Ĭhange the look of the plot with the following options: In this case the inputs were 0, 13 and 100, so 100 values were generated starting at 0 and ending at 13. This function creates an array of numbers evenly spaced between a given start point and a given end point with the number of values created being the third input to the function. ![]() So the jagged edges still exist but they are now too small to be noticeable! Note the function that was used to create the x-data: Numpy’s linspace(). The above example is plotting 100 points and connecting them with straight lines. While it isn’t technically possible to plot a continuous curve using this method, you can at least make the line appear smooth by simply increasing the number of points you plot: import matplotlib.pyplot as plt If you are plotting a continuous function like this it’s usually better to have it be a smooth curve.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |