Skip to content

Commit

Permalink
Limit axes to plot limits
Browse files Browse the repository at this point in the history
  • Loading branch information
eprovst committed Aug 19, 2023
1 parent 2cde596 commit 73036c1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DomainColoring"
uuid = "c24f3079-adb7-4533-8329-9f66732e5e85"
authors = ["Evert Provoost <[email protected]>"]
version = "0.6.0"
version = "0.6.1"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand Down
2 changes: 2 additions & 0 deletions docs/src/usage/cvd.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sweep to display phase instead.
```@example
using CairoMakie, DomainColoring # hide
pdphaseplot(z -> exp(1/z), 0.5)
resize!(current_figure(), 620, 600) #hide
save("pdphaseexample.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -36,6 +37,7 @@ sweep to display phase instead.
```@example
using CairoMakie, DomainColoring # hide
tphaseplot(z -> exp(1/z), 0.5)
resize!(current_figure(), 620, 600) #hide
save("tphaseexample.png", current_figure()) # hide
nothing # hide
```
Expand Down
20 changes: 19 additions & 1 deletion docs/src/usage/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ following.
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sinc, (3, 1.5))
resize!(current_figure(), 620, 340) #hide
save("dcsincphase.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -55,6 +56,7 @@ increase of lightness is taken proportional to the fractional part of
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sinc, (3, 1.5), abs=true)
resize!(current_figure(), 620, 340) #hide
save("dcsincabs.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -65,6 +67,7 @@ of ``f(z)`` is integer by setting `grid = true`.
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sinc, (3, 1.5), grid=true)
resize!(current_figure(), 620, 340) #hide
save("dcsincgrid.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -75,6 +78,7 @@ Of course these options can be combined, the common combination of
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sinc, (3, 1.5), all=true)
resize!(current_figure(), 620, 340) #hide
save("dcsincall.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -93,6 +97,7 @@ checkerplot of the identity function makes this clearer.
```@example
using CairoMakie, DomainColoring # hide
checkerplot(z -> z, 5)
resize!(current_figure(), 620, 600) #hide
save("cprect.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -104,6 +109,7 @@ previous example.
```@example
using CairoMakie, DomainColoring # hide
checkerplot(z -> z, 5, real=true)
resize!(current_figure(), 620, 600) #hide
save("cpreal.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -118,6 +124,7 @@ six bands per ``2\pi`` increase of ``\arg(f(z))``.
```@example
using CairoMakie, DomainColoring # hide
checkerplot(z -> z, 5, polar=true)
resize!(current_figure(), 620, 600) #hide
save("cppolar.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -131,14 +138,18 @@ For example, we get for magnitude:
```@example
using CairoMakie, DomainColoring # hide
checkerplot(z -> z, 5, abs=5)
resize!(current_figure(), 620, 600) #hide
save("cpabs.png", current_figure()) # hide
nothing # hide
```
![](cpabs.png)

and for phase:

```@example
using CairoMakie, DomainColoring # hide
checkerplot(z -> z, 5, angle=10)
resize!(current_figure(), 620, 600) #hide
save("cpangle.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -150,6 +161,7 @@ rate will be chosen for `angle`, for instance:
```@example
using CairoMakie, DomainColoring # hide
checkerplot(sin, (5, 2), polar=4)
resize!(current_figure(), 620, 280) #hide
save("cppolarsin.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -170,17 +182,20 @@ analogous example to the final one of last section, is given by:
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sin, (5, 2), grid=(polar=4,))
resize!(current_figure(), 620, 280) #hide
save("dcpolarsin.png", current_figure()) # hide
nothing # hide
```
![](dcpolarsin.png)

(Note: unlike before, the rate of `angle` need not be even for grids.)

The `abs` argument accepts a different basis from the default ``e``, if
we for instance wanted to see orders of magnitude, we could look at:
```@example
using CairoMakie, DomainColoring # hide
domaincolor(z -> z^3, 5, abs=10)
resize!(current_figure(), 620, 600) #hide
save("dcordermag.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -191,7 +206,8 @@ magnitude itself, they can use the `transform` option, or pass a
function directly to `abs`, for instance:
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sqrt, (-1, 20, -5, 5), abs=z->z)
domaincolor(sqrt, (-1, 19, -4, 4), abs=z->z)
resize!(current_figure(), 620, 280) #hide
save("dclinmag.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -203,6 +219,7 @@ Casorati–Weierstrass theorem:
```@example
using CairoMakie, DomainColoring # hide
domaincolor(z -> exp(1/z), .1, abs=Inf)
resize!(current_figure(), 620, 600) #hide
save("cwthm.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -223,6 +240,7 @@ can add a discretization effect:
using CairoMakie, DomainColoring # hide
discrangle(θ) = DomainColoring.labsweep(π/10 * floor(10/π * θ))
domaincolor(tan, angle=discrangle)
resize!(current_figure(), 620, 600) #hide
save("dscangle.png", current_figure()) # hide
nothing # hide
```
Expand Down
5 changes: 5 additions & 0 deletions docs/src/usage/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Then a simple phase plot can be made using
```@example
using CairoMakie, DomainColoring # hide
domaincolor(z -> 2z + 1)
resize!(current_figure(), 620, 600) #hide
save("simplephaseexample.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -80,6 +81,7 @@ multiplicity. A pole of multiplicity two gives for instance:
```@example
using CairoMakie, DomainColoring # hide
domaincolor(z -> 1 / z^2)
resize!(current_figure(), 620, 600) #hide
save("simplepoleexample.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -93,6 +95,7 @@ axis, as we can see on the following figure.
```@example
using CairoMakie, DomainColoring # hide
domaincolor(sqrt, [-10, 2, -2, 2])
resize!(current_figure(), 620, 250) #hide
save("sqrtexample.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -115,6 +118,7 @@ of the essential singularity of ``e^\frac{1}{z}``.
```@example
using CairoMakie, DomainColoring # hide
domaincolor(z -> exp(1/z), 0.5)
resize!(current_figure(), 620, 600) #hide
save("essentialsingexample.png", current_figure()) # hide
nothing # hide
```
Expand All @@ -133,6 +137,7 @@ options, and the other provided plotting function [`checkerplot`](@ref).
```@example
using CairoMakie, DomainColoring # hide
domaincolor(z -> im*z^3-1, 2.5, all=true)
resize!(current_figure(), 620, 600) #hide
save("logoexample.png", current_figure()) # hide
nothing # hide
```
Expand Down
10 changes: 8 additions & 2 deletions src/DomainColoring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ for (modifying, target) in

fname = modifying ? :shadedplot! : :shadedplot
hname = modifying ? :heatmap! : :heatmap
axis = modifying ? () : (Expr(:kw, :axis, (autolimitaspect = 1,)),)

@eval begin
function $fname(
Expand All @@ -137,7 +136,14 @@ for (modifying, target) in
# parse Makie options
defaults = Attributes(;
interpolate = true,
$(axis...)
$(if modifying
:(()...)
else
Expr(:kw, :axis,
:((autolimitaspect = 1,
aspect = (limits[2] - limits[1]) /
(limits[4] - limits[3]))))
end)
)
attr = merge(Attributes(; kwargs...), defaults)

Expand Down

0 comments on commit 73036c1

Please sign in to comment.