Skip to content
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

Aggressive refactoring #27

Merged
merged 44 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1c4e87e
move old plot impl
jamesrswift Jul 31, 2024
b6d7781
start impl of scientific plot
jamesrswift Jul 31, 2024
ea0d40d
start impl of ternary
jamesrswift Jul 31, 2024
8a81f5c
rename old plot directory
jamesrswift Jul 31, 2024
eb5f2d5
move plot to old
jamesrswift Jul 31, 2024
6f45524
explicitly named exports
jamesrswift Jul 31, 2024
d652d3d
add anchor plot element
jamesrswift Jul 31, 2024
6874579
start on axis lib
jamesrswift Jul 31, 2024
80359b9
copy over legend (TODO: refactor)
jamesrswift Jul 31, 2024
e93c1d1
copy of mark (TODO: refactor)
jamesrswift Jul 31, 2024
9a42d92
begin work on orthorect-2d
jamesrswift Jul 31, 2024
a5012ab
add in support functions (TODO: refactor)
jamesrswift Jul 31, 2024
9f21d9d
stepwise towards grid on orthorect-2s
jamesrswift Jul 31, 2024
ae2bd2c
continue rampage
jamesrswift Jul 31, 2024
544afbd
directory restructure
jamesrswift Jul 31, 2024
86c3474
rampage pt 2
jamesrswift Jul 31, 2024
d64efb3
stepwise towards polar
jamesrswift Jul 31, 2024
ba183aa
further work
jamesrswift Jul 31, 2024
a7f41a4
start defining xy
jamesrswift Jul 31, 2024
8e9f87f
further work
jamesrswift Jul 31, 2024
648bccc
Move clipping logic to axis style
jamesrswift Jul 31, 2024
b06bc20
Move grid to background, better colors
jamesrswift Jul 31, 2024
45c225f
Properly style breakpoints and padding
jamesrswift Aug 1, 2024
799d328
Import violin
jamesrswift Aug 1, 2024
7a40960
Remove old tests from PR
jamesrswift Aug 1, 2024
9d58403
update violin tests
jamesrswift Aug 1, 2024
ecfc863
Add back annotations
jamesrswift Aug 1, 2024
9eee55d
update annotation tests
jamesrswift Aug 1, 2024
1023912
re-add c2a6341
jamesrswift Aug 1, 2024
eae3c4d
Update tests to size page auto with 1cm margin
jamesrswift Aug 1, 2024
31fdf46
import formats properly
jamesrswift Aug 1, 2024
2fd9cb1
add logarithmic axes test pt1
jamesrswift Aug 1, 2024
b0be951
Remove axes/violin (rebase mistake)
jamesrswift Aug 1, 2024
09c9a52
Add error bars back (includes function sig change)
jamesrswift Aug 1, 2024
713b94b
render test for error bars
jamesrswift Aug 1, 2024
9bd7987
Add plot series
jamesrswift Aug 1, 2024
875bfc3
Add back fill-between and test
jamesrswift Aug 1, 2024
4dc325f
Commence work on recreating documentation
jamesrswift Aug 1, 2024
3a6b4e4
update manual and tests
jamesrswift Aug 1, 2024
4f07bb0
Update tests after fixing orthorect ticks bug
jamesrswift Aug 1, 2024
2c4591a
Remove files that should have been gitignored
jamesrswift Aug 1, 2024
e35409f
add tests .gitignore
jamesrswift Aug 1, 2024
6d140f8
further work on manual
jamesrswift Aug 1, 2024
79019f2
Improve manual
jamesrswift Aug 1, 2024
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
64 changes: 46 additions & 18 deletions doc/style.typ
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,50 @@
if type(types) != array {
types = (types,)
}
stack(dir: ttb, spacing: 1em,
// name <type> Default: <default>
block(breakable: false, width: 100%, stack(dir: ltr,
[#text(weight: "bold", name + [:]) #types.map(tidy.styles.default.show-type).join(" or ")],
if show-default {
align(right)[
Default: #raw(
lang: "typc",
// Tidy gives defaults as strings but outside of tidy we pass defaults as the actual values
if in-tidy { default } else { repr(default) }
)
]
}
)),
// text
block(inset: (left: .4cm), content)

block(
breakable: false,
above: 1em, below: 2em, spacing: 1em,
{
block({
box(heading(name, level: 4))
[:]
[#types.map(tidy.styles.default.show-type).join(" or ")]
h(1fr)
if show-default {
[Default: ]
raw(
lang: "typc",
// Tidy gives defaults as strings but outside of tidy we pass defaults as the actual values
if in-tidy { default } else { repr(default) }
)
}
})
block(inset: (left: .4cm), content)
}
)

// block(
// breakable: false,
// above: 1em, below: 2em, spacing: 1em,
// stack(
// dir: ttb, spacing: 1em,
// // name <type> Default: <default>
// block(breakable: false, width: 100%, stack(dir: ltr,
// [#text(weight: "bold", box(heading(name, level: 4)) + [:]) #types.map(tidy.styles.default.show-type).join(" or ")],
// if show-default {
// align(right)[
// Default: #raw(
// lang: "typc",
// // Tidy gives defaults as strings but outside of tidy we pass defaults as the actual values
// if in-tidy { default } else { repr(default) }
// )
// ]
// }
// )),
// // text
// block(inset: (left: .4cm), content)
// ))
}


Expand All @@ -90,7 +117,7 @@
show-parameter-list: show-parameter-list
)

#let parse-show-module(path) = {
#let parse-show-module(path, ..args) = {
tidy.show-module(
tidy.parse-module(
read(path),
Expand All @@ -102,6 +129,7 @@
),
show-outline: false,
sort-functions: none,
style: style
style: style,
..args
)
}
58 changes: 49 additions & 9 deletions doc/util.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "/src/lib.typ" as cetz-plot
#import "/src/cetz.typ"

/// Make the title-page
#let make-title() = {
Expand Down Expand Up @@ -33,30 +34,69 @@
set text(weight: "bold", left-color)
show link: set text(left-color)

block(
block({
place(
top + left,
dx: -left-fringe * 22cm + 5mm,
text(3cm, right-color)[CeTZ]
) +
)
text(3cm)[Plot]
)
block(
v(1cm) +
})

block({
v(1cm)
text(
20pt,
authors.map(v => link(v.at(1), [#v.at(0)])).join("\n")
)
)
block(
v(2cm) +
})
block({
v(2cm)
text(
20pt,
link(
url,
[Version ] + [#cetz-plot.version]
)
)
)
})

block({
v(2cm)
set text(fill: black)
cetz.canvas({
cetz-plot.plot(
size: (8,5),
x-tick-step: calc.pi / 4,
x-minor-tick-step: calc.pi / 16,
x-grid: "both",
x-min: 0, x-max: 2 * calc.pi,
x-format: cetz-plot.axes.format.multiple-of,

y-min: -1, y-max: 1, y-tick-step: 0.5, y-minor-tick-step: 0.1,
y-grid: "both",
{
cetz-plot.add.xy(
calc.sin,
domain: (0,2*calc.pi),
label: $y=x$,
line: "raw",
samples: 100,
epigraph: true,
)

cetz-plot.add.xy(
(t)=>calc.pow(calc.sin(t),2),
domain: (0, 2* calc.pi),
line: "raw",
samples: 100,
hypograph: true,
label: $sin^2 (x)$
)
}
)
})
})

pagebreak(weak: true)
}
66 changes: 66 additions & 0 deletions manual.old.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#import "/doc/util.typ": *
#import "/doc/example.typ": example
#import "/doc/style.typ" as doc-style
#import "/src/lib.typ": *
#import "/src/cetz.typ": *
#import "@preview/tidy:0.2.0"


// Usage:
// ```example
// /* canvas drawing code */
// ```
#show raw.where(lang: "example"): example
#show raw.where(lang: "example-vertical"): example.with(vertical: true)

#make-title()

#set terms(indent: 1em)
#set par(justify: true)
#set heading(numbering: (..num) => if num.pos().len() < 4 {
numbering("1.1", ..num)
})
#show link: set text(blue)

// Outline
#{
show heading: none
columns(2, outline(indent: true, depth: 3))
pagebreak(weak: true)
}

#set page(numbering: "1/1", header: align(right)[CeTZ-Plot])

= Introduction

CeTZ-Plot is a simple plotting library for use with CeTZ.

= Usage

This is the minimal starting point:
#pad(left: 1em)[```typ
#import "@preview/cetz:0.2.2"
#import "@preview/cetz-plot:0.1.0"
#cetz.canvas({
import cetz.draw: *
import cetz-plot: *
...
})
```]
Note that plot functions are imported inside the scope of the `canvas` block.
All following example code is expected to be inside a `canvas` block, with the `plot`
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") {
doc-style.parse-show-module("/src/plot/" + m + ".typ")
}

= Chart

#doc-style.parse-show-module("/src/chart.typ")
#for m in ("barchart", "boxwhisker", "columnchart", "piechart") {
doc-style.parse-show-module("/src/chart/" + m + ".typ")
}
Binary file modified manual.pdf
Binary file not shown.
Loading
Loading