cetz-plot
cetz-plot copied to clipboard
[Tracking] Refactor
When implementing logarithmic plots, and then when implementing polar plots, I ran into the challenge that the axis style has no control over how the data is plotted. This make sense if you treat axis styles as a purely visual element, however, this PR turns them into "drivers" that can change more behaviour of the underlying plot.
This is the initial PR, to allow people a better chance at collaborating on the refactor as well as to give maintainers a better chance at reviewing changes in smaller chunks rather than one hefty PR
Firstly, axis styles have been moved out of axes.typ
(like in a previous draft PR), and instead are located in plot/axis-styles/
. They become modules which must currently provide 3 functions: make-ctx
(responsible for constructing the context within which data is prepared), data-viewport
(responsible for transforming data along any number of axes, and onto the plot itself), and draw-axes
(responsible for drawing the axes).
make-ctx
now supplies an array axes
rather than separately providing x
and y
, as a more general solution for when higher dimensional plots are implemented. It must also provide compute-fill-paths
and compute-stroke-paths
(previously supplied by the util.typ
module) to allow for a finer grained control over clipping (of note: path computation occurs PRIOR to data-viewport transformations)
Plot elements (previously plot.add-<name>()
) are now under plot.add.<name>
, and plot.add
has become plot.add.xy
to disambiguate.
The school-book axis style remains unimplemented but I hope to bring it back at a later stage
To do and Tracking:
- [x] Pull current work into
aggressive-refactor
branch (#27) - [ ] Refactor the refactor: In moving code around a lot, boilerplate code has become prominent. It has been left in this PR because it does not adversely affect the implementation of features, but it is something that will need seeing to as a final step before merging this branch into main
- [ ] Update the manual: Currently failing CI due to having not updated the manual.
- [ ] Change axis styles from being modules to being dictionaries and a constructor to allow for a finer grained control over how any axis style is rendered
Axis Styles
Currently tracked are orthrect-2d
and polar-2d
. Wanted are: barycentric-2d
, polar-3d
, and orthorect-3d
.
Orthorect-2d (previously scientific
axis style)
- [ ] Reintroduce not drawing unset axes
- [ ] School-book axis style
- [x] Verify that logarithmic scales are still working
- [x] Improve clipping function performance (#29)
- [ ] Flipping axes does not appear to work
Polar-2d (previously scientific-polar
)
- [x] Improve clipping function performance (#30)
- [ ] Ticks on axes: I think this can be improved stylistically
- [x] Grid in example in manual seems broken - needs investigating (addressed by c872366 of #31)
Plot elements
- [x]
add.xy
for plotting continuous/continuous data.- [ ] Add thorough tests
- [x] Annotations
- [ ] Area chart (#34)
- [ ] Bar/Column (#31)
- [ ] horizontal bars will be supported through swapped axes and a wrapper
- [ ] Stacked100 isn't exposed to public api https://github.com/cetz-package/cetz-plot/blob/cb8505bb3639e3a6cae730d857a7afee84dee365/src/chart.typ#L1
- [ ] Boxplot
- [ ] Bubble plot
- [ ] Contour
- [x] Error bar
- [ ] Compute stroke paths using clipper
- [x] Violin plot
- [x] Series
- [ ] Marks are not drawn within a series - needs investigation
There are many more plot elements to introduce too, so if anything needs adding to the list, we should.