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

v0.1.0 #33

Closed
wants to merge 90 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 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
5cec42b
Merge pull request #27 from JamesxX/agressive-refactor
johannes-wolf Aug 1, 2024
7117477
fix(clipper): Improved orthorect clipping
johannes-wolf Aug 1, 2024
65e7fcf
Merge pull request #29 from cetz-package/improved-rect-clipping
johannes-wolf Aug 1, 2024
6b76322
fix(clipper): Implement polar clipping
johannes-wolf Aug 1, 2024
fd6118b
Start on bar elements
jamesrswift Aug 1, 2024
dfe2679
Fix `y-base-key` not being saved
jamesrswift Aug 1, 2024
44195e5
update tests
jamesrswift Aug 1, 2024
cf4e1c2
Start shaping chart function signature
jamesrswift Aug 1, 2024
6be438e
Merge pull request #30 from cetz-package/polar-clipping
johannes-wolf Aug 1, 2024
0bd33f2
Stepwise towards bar charts
jamesrswift Aug 1, 2024
b9c223f
temporarily correct drawing of bars
jamesrswift Aug 1, 2024
aa794bb
bar element domain calculated more thoroughly
jamesrswift Aug 2, 2024
499aa21
clustered bar chart WIP
jamesrswift Aug 2, 2024
8e49eb0
Begin work on shaping charts section in manual
jamesrswift Aug 2, 2024
837daad
support stacked bar charts
jamesrswift Aug 2, 2024
06e7e92
Continue shaping manual
jamesrswift Aug 2, 2024
c49195e
Restructure chart directory
jamesrswift Aug 2, 2024
617ebf8
apply styling
jamesrswift Aug 2, 2024
f7a05d7
Don't call canvas ourselves
jamesrswift Aug 2, 2024
46ca1f1
Use plotter for stacked bar chart
jamesrswift Aug 2, 2024
cff839a
update tests
jamesrswift Aug 2, 2024
ba729fe
remove vestigial `example-nocanvas`
jamesrswift Aug 2, 2024
a215206
expose `bar-style` to consumer
jamesrswift Aug 2, 2024
c872366
Fix mistake when calculating distal grid lines
jamesrswift Aug 2, 2024
5f1d0e8
Improve documentation of bar plot element
jamesrswift Aug 2, 2024
86e17a0
Finish manual for bar element, clustered, and stacked
jamesrswift Aug 2, 2024
7a4702e
Add simple bar charts and manual entry
jamesrswift Aug 2, 2024
5bfd74d
Stacked100
jamesrswift Aug 2, 2024
fbdf2b5
Update y-format on stacked bar
jamesrswift Aug 3, 2024
d00c204
gallery: Fix gallery code
johannes-wolf Aug 4, 2024
3766d59
Remove unused code
jamesrswift Aug 5, 2024
b0397b3
resolve out of bounds
jamesrswift Aug 5, 2024
a700813
Add error bar test to clustered
jamesrswift Aug 5, 2024
443806b
Add bar-style test to clustered
jamesrswift Aug 5, 2024
9155ee8
Merge pull request #31 from JamesxX/bar-element
johannes-wolf Aug 5, 2024
60d3fde
Merge branch 'aggressive-refactoring' into bar-element-gallery-fixes
johannes-wolf Aug 5, 2024
cb8505b
Merge pull request #32 from cetz-package/bar-element-gallery-fixes
johannes-wolf Aug 5, 2024
3d90d87
xy: Set default line type to "raw"
johannes-wolf Aug 6, 2024
6688b85
Minor reformatting
johannes-wolf Aug 6, 2024
e49f75c
Pass axis-style as function
johannes-wolf Aug 6, 2024
5b37924
Merge pull request #35 from cetz-package/plot-axis-style-as-function
johannes-wolf Aug 6, 2024
900863e
Ortho 2D: Support hiding axes
johannes-wolf Aug 7, 2024
70d6217
Polar 2D: Support style arguments
johannes-wolf Aug 7, 2024
4336131
Merge pull request #36 from cetz-package/ortho-2d-styling
johannes-wolf Aug 7, 2024
299f741
Update test refs
johannes-wolf Aug 7, 2024
791c3ff
Fix clipper
johannes-wolf Aug 16, 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)
}
18 changes: 8 additions & 10 deletions gallery/barchart.typ
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

#canvas({
draw.set-style(legend: (fill: white))
chart.barchart(mode: "clustered",
size: (9, auto),
label-key: 0,
value-key: (..range(1, 5)),
bar-width: .8,
x-tick-step: 2.5,
data2,
labels: ([Low], [Medium], [High], [Very high]),
legend: "legend.inner-north-east",)
})
chart.bar.clustered(size: (9, 8),
label-key: 0,
y-keys: (..range(1, 5)),
bar-width: .8,
data2,
labels: ([Low], [Medium], [High], [Very high]),
legend: "inner-north-east")
})
8 changes: 4 additions & 4 deletions gallery/line.typ
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@

// Set-up a thin axis style
set-style(axes: (stroke: .5pt, tick: (stroke: .5pt)),
legend: (stroke: none, orientation: ttb, item: (spacing: .3), scale: 80%))
legend: (stroke: none, fill: none, orientation: ttb, item: (spacing: .3), scale: 80%))

plot.plot(size: (12, 8),
x-tick-step: calc.pi/2,
x-format: plot.formats.multiple-of,
x-format: axes.format.multiple-of,
y-tick-step: 2, y-min: -2.5, y-max: 2.5,
legend: "inner-north",
{
let domain = (-1.1 * calc.pi, +1.1 * calc.pi)

for ((title, f)) in fn {
plot.add-fill-between(f, f1, domain: domain,
plot.add.fill-between(f, f1, domain: domain,
style: (stroke: none), label: title)
}
plot.add(f1, domain: domain, label: $ sin x $,
plot.add.xy(f1, domain: domain, label: $ sin x $,
style: (stroke: black))
})
})
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