Tutorial A10¶
1 Take the point p(3, 4)
, and plot it as a circle (marker "o"
). Make the edges of the marker show in black. Set the displayed data area ((\(x_\mathrm{min}\), \(x_\mathrm{max}\)), (\(y_\mathrm{min}\), \(y_\mathrm{max}\))) to ((2, 5), (2, 5))
. Give the plot a title and name the x- and y-axis. Show only the x- and y-coordinates of the point in the x- and y-ticks. Add a data grid (plt.grid
) to the plot.
2 Take the below sequence of x- and y-data points and plot them as dots. Make the connection between the points a dashed gray line. Add axis-labels and a legend describing what can be seen.
x = [x/10 for x in range(-20, 20)]
y = [
0.13533528323661, 0.149568619222635, 0.165298888221586, 0.182683524052734, 0.201896517994655,
0.223130160148429, 0.24659696394160, 0.27253179303401, 0.301194211912202, 0.332871083698079,
0.367879441171442, 0.40656965974059, 0.449328964117221, 0.49658530379140, 0.54881163609402,
0.60653065971263, 0.67032004603563, 0.74081822068171, 0.81873075307798, 0.90483741803595,
1.0, 1.10517091807564, 1.22140275816016, 1.34985880757600, 1.49182469764127, 1.64872127070012,
1.82211880039050, 2.01375270747047, 2.2255409284924, 2.459603111156, 2.7182818284590,
3.00416602394643, 3.32011692273654, 3.66929666761924, 4.05519996684467, 4.48168907033806,
4.9530324243951, 5.47394739172, 6.04964746441294, 6.68589444227926
]
Advanced 1 Continue to work on the plot of 2: Try to use the Figure/Axes instances directly instead of the pyplot convenience functions. Plot the cumulative sum of the data points as diamonds (marker "D"
) of a different color and make the connection between them a dashed gray line as well. Use the function ax.axhline
to draw a solid black line at \(y = 40\). Use the function ax.annotate
to point with an arrow to the first data point in the cumulative sum with
\(y > 40\).