Skip to content

Commit

Permalink
Add bode plot, column plot, scatter plot, and box plot to tests (mix …
Browse files Browse the repository at this point in the history
…of x or y mode, mix of base)
  • Loading branch information
jamesrswift committed Jul 29, 2024
1 parent 1dd02e9 commit f63e3e3
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 3 deletions.
Binary file modified tests/axes/log-mode/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 127 additions & 3 deletions tests/axes/log-mode/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
#import cetz: draw, canvas
#import cetz-plot: axes,

// plot.add test with logarithmic scaling
#box(stroke: 2pt + red, canvas({
import draw: *

plot.plot(
size: (9, 6),
axis-style: "scientific",
y-mode: "log", y-base: 10,
// x-mode: "log",
// x-format: "sci",
y-format: "sci",
x-min: 1, x-max: 10, x-tick-step: 1,
y-min: 1, y-max: 10000, y-tick-step: 1, y-minor-tick-step: 1,
Expand All @@ -32,4 +31,129 @@
)
}
)
}))
}))

// Bode plot test
#box(stroke: 2pt + red,{
canvas({
import draw: *
cetz.draw.set-style(
grid: (stroke: (paint: luma(83.33%), thickness: 1pt, dash: "dotted")),
minor-grid: (stroke: (paint: luma(83.33%), thickness: 0.5pt, dash: "dotted")),
)
plot.plot(
size: (16, 6),
axis-style: "scientific",
x-format: none, x-label: none,
// y-format: "sci",
x-mode: "log",
x-min: 0.01, x-max: 100, x-tick-step: 1, x-minor-tick-step: 1,
y-label: [Magnitude ($upright(d B)$)],
y-min: -40, y-max: 10, y-tick-step: 10,
x-grid: "both",
y-grid: "both",
{
plot.add(domain: (0.01, 100), x => {0})
}
)
})
canvas({
import draw: *
cetz.draw.set-style(
grid: (stroke: (paint: luma(83.33%), thickness: 1pt, dash: "dotted")),
minor-grid: (stroke: (paint: luma(83.33%), thickness: 0.5pt, dash: "dotted")),
)
plot.plot(
size: (16, 6),
axis-style: "scientific",
// y-format: "sci",
x-mode: "log",
x-min: 0.01, x-max: 100, x-tick-step: 1, x-minor-tick-step: 1,
x-label: [Frequency ($upright(r a d)\/s$)],
y-label: [Phase ($upright(d e g)$)],
y-min: -90, y-max: 0, y-tick-step: 45,
x-grid: "both",
y-grid: "both",
{
plot.add(domain: (0.01, 100), x => {-40})
}
)
})
})

// Column chart test
#box(stroke: 2pt + red, canvas({
import draw: *

plot.plot(
size: (9, 6),
axis-style: "scientific",
y-mode: "log", y-base: 10,
// x-mode: "log",
// x-format: "sci",
y-format: "sci",
x-min: -0.5, x-max: 4.5, x-tick-step: 1,
y-min: 0.1, y-max: 10000, y-tick-step: 1, y-minor-tick-step: 1,
x-grid: "both",
y-grid: "both",
{
plot.add-bar(
(1, 10, 100, 1000, 10000).enumerate().map(((x,y))=>{(x,y)}),
bar-width: 0.8,
)
}
)
}))

// Scatter plot test
#box(stroke: 2pt + red, canvas({
import draw: *

plot.plot(
size: (9, 6),
axis-style: "scientific",
y-mode: "log", y-base: 100,
// x-mode: "log",
// x-format: "sci",
y-format: "sci",
x-min: -0.5, x-max: 4.5, x-tick-step: 1,
y-min: 0.1, y-max: 10000, y-tick-step: 1, y-minor-tick-step: 10,
x-grid: "both",
y-grid: "both",
{
plot.add(
((0, 1),(1,2),(1,3),(2, 100),(2,150),(3, 1000),),
style: (stroke: none),
mark: "o"
)
}
)
}))

// Box plot test
#box(stroke: 2pt + red, canvas({
import draw: *

plot.plot(
size: (9, 6),
axis-style: "scientific",
y-mode: "log", y-base: 10,
// x-mode: "log",
// x-format: "sci",
y-format: "sci",
x-min: -0.5, x-max: 2.5, x-tick-step: 1,
y-min: 0.1, y-max: 15000, y-tick-step: 1, y-minor-tick-step: 1,
x-grid: "both",
y-grid: "both",
{
plot.add-boxwhisker(
(
(x: 0, min: 1, q1: 10, q2: 100, q3: 1000, max: 10000),
(x: 1, min: 100, q1: 200, q2: 300, q3: 400, max: 500),
(x: 2, min: 10, q1: 100, q2: 500, q3: 1000, max: 5000),
),
)
}
)
}))

0 comments on commit f63e3e3

Please sign in to comment.