Skip to content

Commit 2cde596

Browse files
committed
Added high contrast mode to checkerplot
1 parent 3334810 commit 2cde596

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

DomainColoringToy/src/DomainColoringToy.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ Numbers can be provided instead of booleans to override the default rates.
329329
330330
- **`phase`** is a shortcut for `angle = true` and `abs = true`.
331331
332+
- **`hicontrast`** uses black and white instead of the softer defaults.
333+
332334
Remaining keyword arguments are passed to Makie.
333335
"""
334336
function checkerplot(
@@ -341,11 +343,12 @@ function checkerplot(
341343
angle = false,
342344
abs = false,
343345
polar = false,
346+
hicontrast = false,
344347
kwargs...
345348
)
346349

347350
interactiveshadedplot(f, w -> DC.checkerplotshader(
348-
w; real, imag, rect, angle, abs, polar
351+
w; real, imag, rect, angle, abs, polar, hicontrast
349352
), limits, pixels; kwargs...)
350353
end
351354

docs/src/usage/general.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ nothing # hide
155155
```
156156
![](cppolarsin.png)
157157

158+
Finally, `hicontrast = true` can be used to plot in black and white
159+
instead of the slightly softer defaults.
160+
158161
## The [`domaincolor`](@ref) function, revisited
159162

160163
Like [`checkerplot`](@ref), `abs` and `grid` also accept numbers.

src/DomainColoring.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ domaincolor, domaincolor!
475475
@warn "angle, abs, and grid are all false, domain coloring will be a constant color."
476476
end
477477
w -> domaincolorshader(w; angle, abs, grid, all)
478-
end
479-
)
478+
end)
480479

481480
"""
482481
DomainColoring.pdphaseplotshader(w :: Complex)
@@ -589,6 +588,7 @@ tphaseplot, tphaseplot!
589588
angle = false,
590589
abs = false,
591590
polar = false,
591+
hicontrast = false,
592592
)
593593
594594
Takes a complex value **`w`** and shades it as in a checker plot.
@@ -603,10 +603,16 @@ function checkerplotshader(
603603
angle = false,
604604
abs = false,
605605
polar = false,
606+
hicontrast = false,
606607
)
607608

608609
g = _grid(CheckerGrid, w; real, imag, rect, angle, abs, polar)
609-
return Gray(0.9g + 0.08)
610+
611+
if hicontrast
612+
Gray(g)
613+
else
614+
Gray(0.9g + 0.08)
615+
end
610616
end
611617

612618
export checkerplot, checkerplot!
@@ -622,6 +628,7 @@ export checkerplot, checkerplot!
622628
angle = false,
623629
abs = false,
624630
polar = false,
631+
hicontrast = false,
625632
kwargs...
626633
)
627634
@@ -660,6 +667,8 @@ Numbers can be provided instead of booleans to override the default rates.
660667
661668
- **`phase`** is a shortcut for `angle = true` and `abs = true`.
662669
670+
- **`hicontrast`** uses black and white instead of the softer defaults.
671+
663672
Remaining keyword arguments are passed to Makie.
664673
"""
665674
checkerplot, checkerplot!
@@ -670,9 +679,10 @@ checkerplot, checkerplot!
670679
rect = false,
671680
angle = false,
672681
abs = false,
673-
polar = false),
682+
polar = false,
683+
hicontrast = false),
674684
w -> checkerplotshader(
675-
w; real, imag, rect, angle, abs, polar
685+
w; real, imag, rect, angle, abs, polar, hicontrast
676686
))
677687

678688
end

0 commit comments

Comments
 (0)