Closed Andrew15-5 closed 1 year ago
A related problem is that I can't just write x => calc.sqrt(5 - calc.pow((x - 1), 2)) + 1
, because I have to provide a valid domain, no more (will give an error) no less (won't be a complete circle). This introduces a manual and painful offset guessing:
Ok, I am very interested in implementing contour plots. But I am not sure when I've got time to do so.
I find it frustrating that I couldn't achieve the same simplicity of the input and the same complexity of the output with matplotlib as I did with Desmos:
It would be perfect if cetz can compete with this app in terms of contour plotting + area filling (if the condition has less/greater signs), because Desmos can only save plots to the cloud, not into downloadable files (unlike typst+cetz).
Hello @Andrew15-5, I have started work on contour plots. Are you using Typst localy? If so, can you try out the branch of the linked PR? Filling does not yet work, though. See the tests of the PR for an example.
It currently also results in pretty strange plots sometimes… :grin: It is too late for me, maybe.
Btw. https://www.geogebra.org/graphing allows you to export plots as SVG and Desmos does, too. Although the export options are quite limited.
can you try out the branch of the linked PR?
I'm not sure when I can, but not right now. Maybe a bit later. Looks good though.
Btw. https://www.geogebra.org/graphing allows you to export plots as SVG and Desmos does, too.
Oh, I forgot that Desmos has a web version. Yes, it's all very limited, but at least I have some options, thanks.
Filling does not yet work
It can "not work" if the contour is out of the visible bounds:
But it works (without color blending) if the limit is visible:
It's very rough, but it's a good start. I also have to wait for more than 15 seconds for it to compile (with set max settings).
P.S. This is what I plotted in Desmos (mobile app) before opening this issue.
I could improve it a lot (there was a bug in the interpolation):
The upper example uses 25x25 samples, the lower 50x50 samples. Filling now also works correctly. The changes are not yet pushed.
Merged to 0.2.0 branch.
I think most libraries have struggled with easily drawing circles where the function has both x and y as its parameters. Matplotlib has a contour function that takes
x
andy
list and thef(x, y)
. pgfplots only supports drawing upper and lower halves of a circle. Same with cetz. I was wondering if it is possible to straight up write(x, y) => calc.pow(x - 1, 2) + calc.pow(y - 1, 2) == 9
. The problem is thatdomain
is only forx
and normal function isf(x) = float
and notf(x, y) = boolean
. Is it possible to make an "exception" for drawing circles (ellipses)?Another function example can be a
(x, y) => (x - 1) * (y - 1) == 1
, but in this case it can be transformed into function with 1 argument (no square roots).Related: cetz-package/cetz-plot#4.