@@ -13,26 +13,38 @@ User guide
1313
1414 .. plot ::
1515
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]
1821 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+
2941
3042 .. toctree ::
3143 :maxdepth: 1
3244
3345 getting_started/index.rst
3446 installing/index.rst
35- faq/index.rst
47+ FAQ: How-to and troubleshooting < faq/index.rst >
3648
3749 .. grid-item-card :: Users guide
3850 :padding: 2
0 commit comments