Skip to content

Merge main into refactor-plot-part-one #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified manual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module imported into the namespace.
= Plot

#doc-style.parse-show-module("/src/plot.typ")
#for m in ("line", "bar", "boxwhisker", "contour", "errorbar", "annotation", "formats", "violin") {
#for m in ("line", "bar", "boxwhisker", "contour", "errorbar", "annotation", "formats", "violin", "legend") {
doc-style.parse-show-module("/src/plot/" + m + ".typ")
}

Expand Down
4 changes: 2 additions & 2 deletions src/plot.typ
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@
axis.used = true

let domain = if i == 0 {
d.at("x-domain", default: (0, 0))
d.at("x-domain", default: (none, none))
} else {
d.at("y-domain", default: (0, 0))
d.at("y-domain", default: (none, none))
}
if domain != (none, none) {
axis.min = util.min(axis.min, ..domain)
Expand Down
12 changes: 9 additions & 3 deletions src/plot/legend.typ
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
/// - mark: (none,string): Legend mark symbol
/// - mark-style: (none,dictionary): Mark style
/// - mark-size: (number): Mark size
/// - style (styles): Style keys for the single item
/// - ..style (styles): Style keys for the single item
#let item(label, preview, mark: none, mark-style: (:), mark-size: 1, ..style) = {
assert.eq(style.pos().len(), 0,
message: "Unexpected positional arguments")
Expand Down Expand Up @@ -217,8 +217,14 @@
/// If set to `auto`, a straight line is drawn.
///
/// ```example
/// add-legend([Custom item], preview _ => {
/// draw.rect((0,0), (1,1)) // Draw a rect as preview
/// plot.plot(size: (1,1), x-tick-step: none, y-tick-step: none, {
/// plot.add(((0,0), (1,1))) // Some data
/// plot.add-legend([Custom item], preview: () => {
/// import cetz.draw: *
/// circle((.5,.5), radius: .5) // Draw a custom preview
/// // between (0,0) and (1,1)
/// })
/// plot.add-legend([Another item])
/// })
/// ```
#let add-legend(label, preview: auto) = {
Expand Down
Binary file modified tests/plot/annotation/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.
12 changes: 12 additions & 0 deletions tests/plot/annotation/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,15 @@
})
})
})

#test-case({
import draw: *
set-style(rect: (stroke: none))

plot.plot(size: (6, 4), x-tick-step: 1, {
plot.add(domain: (100, 101), calc.sin)
plot.annotate(padding: .1, {
content( (101.5, 0), [A])
})
})
})
Loading