@@ -13,26 +13,38 @@ User guide
13
13
14
14
.. plot ::
15
15
16
- x = np.linspace(0, 2, 100) # Sample data.
17
-
16
+ rng = np.random.default_rng(seed=19680808)
17
+ x = np.linspace(0, 4, 1000) # Sample data.
18
+ y = rng.normal(size=len(x)) * 1.5 + x**2 + np.cumsum(rng.normal(size=len(x))) / 6
19
+ x = x[::10]
20
+ y = y[::10]
18
21
fig, ax = plt.subplots(figsize=(5, 2.7), layout='constrained')
19
- ax.scatter(x, np.random.randn(len(x)) + x**2,
20
- s=13 * np.random.rand(len(x)), c=np.random.randn(len(x)),
21
- label='noisy data')
22
- ax.plot(x, x, label='linear') # Plot some data on the axes.
23
- ax.plot(x, x**2, label='quadratic') # Plot more data on the axes...
24
- ax.plot(x, x**3, label='cubic') # ... and some more.
25
- ax.set_xlabel('x label') # Add an x-label to the axes.
26
- ax.set_ylabel('y label') # Add a y-label to the axes.
27
- ax.set_title("Simple plot") # Add a title to the axes.
28
- ax.legend() # Add a legend.
22
+
23
+ ax.plot(x, x**2, label='underlying data', linewidth=4, alpha=0.6, color='k')
24
+ ax.scatter(x, y, s=13 * rng.random(size=len(x)), c=rng.normal(size=len(x)),
25
+ label='noisy data')
26
+ # p = np.polyfit(x, y, deg=1)
27
+ # print(p)
28
+ p = np.array([ 3.81283983, -2.00111268])
29
+ out = np.polyval(p, x)
30
+ ax.plot(x, out, label='linear fit') # Plot some data on the axes.
31
+ # p = np.polyfit(x, y, deg=2)
32
+ # print(p)
33
+ p = np.array([ 1.18076933, -0.86768725, 1.05989268])
34
+ out = np.polyval(p, x)
35
+ ax.plot(x, out, label='quadratic fit')
36
+ ax.set_xlabel('x label')
37
+ ax.set_ylabel('y label')
38
+ ax.set_title("Simple plot")
39
+ ax.legend()
40
+
29
41
30
42
.. toctree ::
31
43
:maxdepth: 1
32
44
33
45
getting_started/index.rst
34
46
installing/index.rst
35
- faq/index.rst
47
+ FAQ: How-to and troubleshooting < faq/index.rst >
36
48
37
49
.. grid-item-card :: Users guide
38
50
:padding: 2
0 commit comments