use quarto, not Pluto to render pages
This commit is contained in:
@@ -75,10 +75,8 @@ using Plots
|
||||
```
|
||||
|
||||
|
||||
```julia;echo=false
|
||||
note("""
|
||||
`Plots` is a frontend for one of several backends. `Plots` comes with a backend for web-based graphics (call `plotly()` to specify that); a backend for static graphs (call `gr()` for that). If the `PyPlot` package is installed, calling `pyplot()` will set that as a backend. For terminal usage, if the `UnicodePlots` package is installed, calling `unicodeplots()` will enable that usage. There are still other backends.""")
|
||||
```
|
||||
!!! note
|
||||
`Plots` is a frontend for one of several backends. `Plots` comes with a backend for web-based graphics (call `plotly()` to specify that); a backend for static graphs (call `gr()` for that). If the `PyPlot` package is installed, calling `pyplot()` will set that as a backend. For terminal usage, if the `UnicodePlots` package is installed, calling `unicodeplots()` will enable that usage. There are still other backends.
|
||||
|
||||
The `plotly` backend is part of the `Plots` package, as is `gr`. Other backends require installation, such as `PyPlot` and `PlotlyJS`.
|
||||
We use `gr` in these notes, for the most part. (The `plotly` backend is also quite nice for interactive usage, but doesn't work as well with the static HTML pages.)
|
||||
@@ -112,11 +110,9 @@ Plotting a function is then this simple: `plot(f, xmin, xmax)`.
|
||||
> style, where the details to execute the action are only exposed as
|
||||
> needed.
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
The time to first plot can feel sluggish, but subsequent plots will be speedy. See the technical note at the end of this section for an explanation.
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
The time to first plot can feel sluggish, but subsequent plots will be speedy. See the technical note at the end of this section for an explanation.
|
||||
|
||||
|
||||
Let's see some other graphs.
|
||||
|
||||
@@ -165,16 +161,12 @@ plot(x -> mxplusb(x, (m=-1, b=1)), -1, 2)
|
||||
```
|
||||
|
||||
|
||||
```julia;echo=false
|
||||
note("""
|
||||
!!! note
|
||||
The function object in the general pattern `action(function, args...)`
|
||||
is commonly specified in one of three ways: by a name, as with `f`; as an
|
||||
anonymous function; or as the return value of some other action
|
||||
through composition.
|
||||
|
||||
The function object in the general pattern `action(function, args...)`
|
||||
is commonly specified in one of three ways: by a name, as with `f`; as an
|
||||
anonymous function; or as the return value of some other action
|
||||
through composition.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
Anonymous functions are also created by `Julia's` `do` notation, which is useful when the first argument to function (like `plot`) accepts a function:
|
||||
|
||||
@@ -186,11 +178,9 @@ end
|
||||
|
||||
The `do` notation can be a bit confusing to read when unfamiliar, though its convenience makes it appealing.
|
||||
|
||||
```julia; echo=false
|
||||
note("""
|
||||
Some types we will encounter, such as the one for symbolic values or the special polynomial one, have their own `plot` recipes that allow them to be plotted similarly as above, even though they are not functions.
|
||||
""")
|
||||
```
|
||||
!!! note
|
||||
Some types we will encounter, such as the one for symbolic values or the special polynomial one, have their own `plot` recipes that allow them to be plotted similarly as above, even though they are not functions.
|
||||
|
||||
|
||||
----
|
||||
|
||||
@@ -248,22 +238,6 @@ pts_needed(x -> 10x, 0, 10), pts_needed(x -> sin(10x), 0, 10)
|
||||
(In fact, the `21` is the minimum number of points used for any function; a linear function only needs two.)
|
||||
|
||||
|
||||
##### Example
|
||||
|
||||
This demo (which is interactive within a `Pluto` session) shows more points are needed as the function becomes more "curvy." There are the minimum of ``21`` for a straight line, ``37`` for a half period, ``45`` for a full period, etc.
|
||||
|
||||
```julia; echo=false
|
||||
md"""
|
||||
n = $(@bind 𝐧 Slider(0:20, default=1))
|
||||
"""
|
||||
```
|
||||
|
||||
```julia; hold=true;
|
||||
xs,ys = unzip(x -> sin(𝐧*x*pi), 0, 1)
|
||||
plot(xs, ys, title="n=$(length(xs))")
|
||||
scatter!(xs, ys)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
For instances where a *specific* set of ``x`` values is desired to be
|
||||
@@ -495,16 +469,12 @@ The ``3`` main functions used in these notes for adding layers are:
|
||||
* `annotate!((x,y, label))` to add a label at $(x,y)$
|
||||
|
||||
|
||||
```julia;echo=false
|
||||
alert("""
|
||||
!!! warning
|
||||
Julia has a convention to use functions named with a `!` suffix to
|
||||
indicate that they mutate some object. In this case, the object is the
|
||||
current graph, though it is implicit. Both `plot!`, `scatter!`, and
|
||||
`annotate!` (others too) do this by adding a layer.
|
||||
|
||||
Julia has a convention to use functions named with a `!` suffix to
|
||||
indicate that they mutate some object. In this case, the object is the
|
||||
current graph, though it is implicit. Both `plot!`, `scatter!`, and
|
||||
`annotate!` (others too) do this by adding a layer.
|
||||
|
||||
""")
|
||||
```
|
||||
|
||||
## Additional arguments
|
||||
|
||||
@@ -709,8 +679,8 @@ choices = ["`(-Inf, -1)` and `(0,1)`",
|
||||
"`(-Inf, -0.577)` and `(0.577, Inf)`",
|
||||
"`(-1, 0)` and `(1, Inf)`"
|
||||
];
|
||||
ans=3;
|
||||
radioq(choices, ans)
|
||||
answ=3;
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -737,8 +707,8 @@ choices = ["`(-Inf, -3)` and `(0, 1)`",
|
||||
"`(-3, 0)` and `(1, Inf)`",
|
||||
"`(-Inf, -4.1)` and `(1.455, Inf)`"
|
||||
];
|
||||
ans=2;
|
||||
radioq(choices, ans)
|
||||
answ=2;
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -787,15 +757,15 @@ choices = [
|
||||
"`f(x) = x <= 4 ? 35.0 : 35.0 + 10.0 * (x-4)`",
|
||||
"`f(x) = x <= 10 ? 35.0 : 35.0 + 4.0 * (x-10)`"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
answ = 3
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
Make a plot of the model. Graphically estimate how many bags of trash will cost 55 dollars.
|
||||
|
||||
```julia; hold=true;echo=false
|
||||
ans = 15
|
||||
numericq(ans, .5)
|
||||
answ = 15
|
||||
numericq(answ, .5)
|
||||
```
|
||||
|
||||
###### Question
|
||||
@@ -829,8 +799,8 @@ What is seen?
|
||||
choices = [L"It oscillates wildly, as the period is $T=2\pi/(500 \pi)$ so there are 250 oscillations.",
|
||||
"It should oscillate evenly, but instead doesn't oscillate very much near 0 and 1",
|
||||
L"Oddly, it looks exactly like the graph of $f(x) = \sin(2\pi x)$."]
|
||||
ans = 3
|
||||
radioq(choices, ans)
|
||||
answ = 3
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
The algorithm to plot a function works to avoid aliasing issues. Does the graph generated by `plot(f, 0, 1)` look the same, as the one above?
|
||||
@@ -840,8 +810,8 @@ choices = ["Yes",
|
||||
"No, but is still looks pretty bad, as fitting 250 periods into a too small number of pixels is a problem.",
|
||||
"No, the graph shows clearly all 250 periods."
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -865,8 +835,8 @@ choices = [
|
||||
"An ellipse",
|
||||
"A straight line"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans)
|
||||
answ = 2
|
||||
radioq(choices, answ)
|
||||
```
|
||||
|
||||
|
||||
@@ -898,8 +868,8 @@ choices = [
|
||||
"A straight line",
|
||||
"None of the above"
|
||||
]
|
||||
ans = 1
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 1
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -917,8 +887,8 @@ choices = [
|
||||
"A straight line",
|
||||
"None of the above"
|
||||
]
|
||||
ans = 3
|
||||
radioq(choices, ans,keep_order=true)
|
||||
answ = 3
|
||||
radioq(choices, answ,keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -936,8 +906,8 @@ choices = [
|
||||
"A straight line",
|
||||
"None of the above"
|
||||
]
|
||||
ans = 2
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 2
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
|
||||
@@ -956,8 +926,8 @@ choices = [
|
||||
"A straight line",
|
||||
"None of the above"
|
||||
]
|
||||
ans = 5
|
||||
radioq(choices, ans, keep_order=true)
|
||||
answ = 5
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user