em dash; sentence case
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# The Graph of a Function
|
||||
# The graph of a function
|
||||
|
||||
|
||||
{{< include ../_common_code.qmd >}}
|
||||
@@ -254,10 +254,10 @@ nothing
|
||||
|
||||
|
||||
|
||||
----
|
||||
---
|
||||
|
||||
|
||||
Making a graph with `Plots` is easy, but producing a graph that is informative can be a challenge, as the choice of a viewing window can make a big difference in what is seen. For example, trying to make a graph of $f(x) = \tan(x)$, as below, will result in a bit of a mess - the chosen viewing window crosses several places where the function blows up:
|
||||
Making a graph with `Plots` is easy, but producing a graph that is informative can be a challenge, as the choice of a viewing window can make a big difference in what is seen. For example, trying to make a graph of $f(x) = \tan(x)$, as below, will result in a bit of a mess---the chosen viewing window crosses several places where the function blows up:
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -536,16 +536,16 @@ The `Plots` package uses positional arguments for input data and keyword argumen
|
||||
The `Plots` package provides many such arguments for adjusting a graphic, here we mention just a few:
|
||||
|
||||
|
||||
* `plot(...; title="main title", xlab="x axis label", ylab="y axis label")`: add title and label information to a graphic
|
||||
* `plot(...; color="green")`: this argument can be used to adjust the color of the drawn figure (color can be a string,`"green"`, or a symbol, `:green`, among other specifications)
|
||||
* `plot(...; linewidth=5)`: this argument can be used to adjust the width of drawn lines
|
||||
* `plot(...; linestyle=:dash)`: will change the line style of the plotted lines to dashed lines. Also `:dot`, ...
|
||||
* `plot(...; title="main title", xlabel="x axis label", ylabel="y axis label")`: add title and label information to a graphic
|
||||
* `plot(...; label="a label")` the `label` attribute will show up when a legend is present. Using an empty string, `""`, will suppress add the layer to the legend.
|
||||
* `plot(...; legend=false)`: by default, different layers will be indicated with a legend, this will turn off this feature
|
||||
* `plot(...; xlims=(a,b), ylims=(c,d))`: either or both `xlims` and `ylims` can be used to control the viewing window
|
||||
* `plot(...; xticks=[xs..], yticks=[ys...]: either or both `xticks` and `yticks` can be used to specify where the tick marks are to be drawn
|
||||
* `plot(...; aspect_ratio=:equal)`: will keep $x$ and $y$ axis on same scale so that squares look square.
|
||||
* `plot(...; framestyle=:origin)`: The default `framestyle` places $x$-$y$ guides on the edges; this specification places them on the $x-y$ plane.
|
||||
* `plot(...; color="green")`: this argument can be used to adjust the color of the drawn figure (color can be a string,`"green"`, or a symbol, `:green`, among other specifications)
|
||||
* `plot(...; linewidth=5)`: this argument can be used to adjust the width of drawn lines
|
||||
* `plot(...; linestyle=:dash)`: will change the line style of the plotted lines to dashed lines. Also `:dot`, ...
|
||||
|
||||
|
||||
For plotting points with `scatter`, or `scatter!` the markers can be adjusted via
|
||||
@@ -583,7 +583,7 @@ With these assumptions, we have an initial decision to make:
|
||||
We re-express our equation $y=f(x)= mx+b$ in general form $f(x,y) = 0 = Ax + By + C$. Using the other point on the line $A=-(y_1-y_0)$, $B=(x_1-x_0)$, and $C = -x_1y_0 + x_0 y_1$. In particular, by assumption both $A$ and $B$ are positive.
|
||||
|
||||
|
||||
With this, we have $f(x_0,y_0) = 0$. But moreover, any point with $y>y_0$ will have $f(x_0,y)>0$ and if $y < y_0$ the opposite. That is this equation divides the plane into two pieces depending on whether $f$ is positive, the line is the dividing boundary.
|
||||
With this, we have $f(x_0,y_0) = 0$. But moreover, any point $(x_0,y)$ with $y>y_0$ will have $f(x_0,y)>0$ and if $y < y_0$ the opposite. That is this equation divides the plane into two pieces depending on whether $f$ is positive---the line is the dividing boundary.
|
||||
|
||||
For the algorithm, we start at $(x_0, y_0)$ and ask if the pixel $(x_0 + 1, y_0)$ or $(x_0 + 1, y_0 - 1)$ will be lit, then we continue to the right.
|
||||
|
||||
@@ -637,7 +637,7 @@ Two basic objects to graph are points and lines. Add to these polygons.
|
||||
|
||||
A point in two-dimensional space has two coordinates, often denoted by $(x,y)$. In `Julia`, the same notation produces a `tuple`. Using square brackets, as in `[x,y]`, produces a vector. Vectors are are more commonly used in these notes, as we have seen there are algebraic operations defined for them. However, tuples have other advantages and are how `Plots` designates a point.
|
||||
|
||||
The plot command `plot(xs, ys)` plots the points $(x_1,y_1), \dots, (x_n, y_n)$ and then connects adjacent points with with lines. The command `scatter(xs, ys)` just plots the points.
|
||||
The plot command `plot(xs, ys)` plots the points $(x_1,y_1), \dots, (x_n, y_n)$ and then connects adjacent points with lines. The command `scatter(xs, ys)` just plots the points.
|
||||
|
||||
However, the points might be more naturally specified as coordinate pairs. If tuples are used to pair them off, then `Plots` will plot a vector of tuples as a sequence of points through `plot([(x1,y1), (x2, y2), ..., (xn, yn)])`:
|
||||
|
||||
@@ -711,7 +711,7 @@ scatter!(f.(θs), g.(θs))
|
||||
---
|
||||
|
||||
|
||||
As with the plot of a univariate function, there is a convenience interface for these plots - just pass the two functions in:
|
||||
As with the plot of a univariate function, there is a convenience interface for these plots---just pass the two functions in:
|
||||
|
||||
|
||||
```{julia}
|
||||
@@ -777,8 +777,9 @@ Playing with the toy makes a few things become clear:
|
||||
|
||||
These all apply to parametric plots, as the Etch A Sketch trace is no more than a plot of $(f(t), g(t))$ over some range of values for $t$, where $f$ describes the movement in time of the left knob and $g$ the movement in time of the right.
|
||||
|
||||
---
|
||||
|
||||
Now, we revisit the last problem in the context of this. We saw in the last problem that the parametric graph was nearly a line - so close the eye can't really tell otherwise. That means that the growth in both $f(t) = t^3$ and $g(t)=t - \sin(t)$ for $t$ around $0$ are in a nearly fixed ratio, as otherwise the graph would have more curve in it.
|
||||
Now, we revisit the last problem in the context of this. We saw in the last problem that the parametric graph was nearly a line---so close the eye can't really tell otherwise. That means that the growth in both $f(t) = t^3$ and $g(t)=t - \sin(t)$ for $t$ around $0$ are in a nearly fixed ratio, as otherwise the graph would have more curve in it.
|
||||
|
||||
|
||||
##### Example: Spirograph
|
||||
@@ -1136,14 +1137,3 @@ choices = [
|
||||
answ = 5
|
||||
radioq(choices, answ, keep_order=true)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Technical note
|
||||
|
||||
|
||||
The slow "time to first plot" in `Julia` is a well-known hiccup that is related to how `Julia` can be so fast. Loading Plots and the making the first plot are both somewhat time consuming, though the second and subsequent plots are speedy. Why?
|
||||
|
||||
|
||||
`Julia` is an interactive language that attains its speed by compiling functions on the fly using the [llvm](llvm.org) compiler. When `Julia` encounters a new combination of a function method and argument types it will compile and cache a function for subsequent speedy execution. The first plot is slow, as there are many internal functions that get compiled. This has sped up of late, as excessive recompilations have been trimmed down, but still has a way to go. This is different from "precompilation" which also helps trim down time for initial executions. There are also some more technically challenging means to create `Julia` images for faster start up that can be pursued if needed.
|
||||
|
||||
Reference in New Issue
Block a user