#πŸ“ˆ Lilaq gets 0.1.0 years old βˆ’ Plotting and scientific data visualization

1 messages Β· Page 1 of 1 (latest)

minor cape
#

Today is official Ο€-day and also Einstein's Birthday! What a perfect occasion to release a scientific data plotting framework. (And no, it wasn't planned this way!)

Many of you have heard of this project through the talk at the recent Typst meetup. Now, we are excited to announce that the package is finally available.

Lilaq is a data visualization package for Typst, combining the:

  • Ease of use and fast learning curve of Matplotlib, making it accessible for beginners.

  • Possibilities of document integration and uniform styling of PGFplots, ensuring professional and consistent visual output.

It is easy to learn, features powerful configuration and preset creation through mock-up custom elements, and benefits from the real-time preview of Typst. Due to its use of the package Zero, consistent number formatting with the rest of the document can be guaranteed.

If you like Lilaq, you can support this immense endeavor with:

Lilaq has a website! The entire documentation, filled with tutorials, examples, and detailed technical references, lives at:

Below you can find a simple usage example.

#import "@preview/lilaq:0.1.0" as lq

#let xs = (0, 1, 2, 3, 4)

#lq.diagram(
  title: [Data],
  xlabel: $x$, 
  ylabel: $y$,

  lq.plot(xs, (5, 4, 2, 1, 2), mark: "s", label: [A]),
  lq.plot(xs, (2, 5, 4, 2, 3), mark: "o", label: [B])
)
dense mural
#

I just sponsored Mc-Zen. Go sponsor your open source dependencies!

lone warren
#

aaaaaahh let’s go, well done!!

open ferry
#

Very cool! Any plan to generate a .pdf documentation? Somehow, your website is automatically placed in sandbox mode by my company's security SW. I could not even copy any demo code to try out 🀣

minor cape
# open ferry Very cool! Any plan to generate a .pdf documentation? Somehow, your website is a...

There was a problem with indexing from Googles side because they crawled the url before I published the page. I'm working on fixing that, maybe you're issue is related? I don't really know anything about web security. There are no plans to generate a .pdf documentation currently because of the great implementation burden of maintaining both a web and a downloadable version (I want to work on the code too haha). Instead I'd like to fix this security issue is possible.

open ferry
#

Fair enough! Hope the security concern can be lifted after you fix that issue. BTW, I really like your 'borrowing' the matplotlib conventions and styles as matplotlib has been my key plotting tool in the recent years. Its capability for all kinds of niche customization is super useful.

dense mural
#

No worries. You've given talks, multiple packages, and a release with documents. Completely insane that you only have 3 sponsors. Let's get these numbers up people.... πŸ˜‚

timber crest
#

Have you guys thought about integration of cetz and lilaq?

lone warren
#

is it possible to easily scale an axis in terms of pi? so i'd have 0, 1/2pi, 1pi etc.?

#

@minor cape

#

?r ```
#import "@preview/lilaq:0.1.0" as lq
#import "@preview/eqalc:0.1.3": math-to-data

$ f(x) = 2 dot sin(x - 1/2pi) $ <f>
#context figure({
let max = 2*calc.pi
let x = lq.linspace(0, max)
let data = math-to-data(<f>)
lq.diagram(
lq.plot(x, x.map(data.func), label: data.x-math),
xaxis: none,
lq.axis(
ticks: range(int(max/calc.pi)2+1).map(x=>x/2calc.pi)
)
)
})

dire thunderBOT
lone warren
#

got this rn

minor cape
#

?render theme=light

#import "@preview/lilaq:0.1.0" as lq
#import "@preview/eqalc:0.1.3": math-to-data

$ f(x) = 2 dot sin(x - 1/2pi) $ <f>
#context figure({
  let max = 2*calc.pi
  let x = lq.linspace(0, max)
  let data = math-to-data(<f>)
  lq.diagram(
    lq.plot(x, x.map(data.func), label: data.x-math),
    xaxis: (
      ticks: (
        ticks: (0, calc.pi, calc.pi*2),
        labels: ($0$, $pi$, $2pi$)
      )
    )
  )
})
minor cape
#

Note that it I would recommend to configure the main axis through axis (as in my example) instead of axis: none and creating a new lq.xaxis.

minor cape
# timber crest Have you guys thought about integration of cetz and lilaq?

I'm not entirely sure what kind of integration you mean. It is of course possible to put a lilaq diagram into a cetz graphic through cetz.draw.content and conversely, it is possible to insert a cetz graphic into a lilaq diagram through lq.place.

Aside from that, Lilaq takes an entirely different approach. Instead of a "draw state" like the one cetz uses, everything is realized through elements that can be individually or sometimes collectively addressed for styling and customization.

#

This is by the way also the reason why Lilaq is standalone and does not build on cetz. When I started work on this project, cetz had only barebone support for plotting (yes this was in October 2023) but already then my vision differed too much from the approach taken with cetz-plot.

#

Plotting with diagrams poses completely different constraints than free drawing, mainly concerning layout and styling.

While I will freely admit that I love PGFplots, I don't think it is intuitive to use and I don't think it is ideal to have these axis environments just as giant macros inside a tikzpicture. For example it leads to all kinds of problems diagram grids etc. and makes everything behave not quite as one would expect.

#

That is why I chose the Matplotlib way.

minor cape
stable copper
#

a couple days ago I saw that like video on Typst of ya'll presenting it and I got so hyped

dire jacinth
dusk timber
#

This is amazing!

minor cape
sweet nexus
#

I wrongly read that if you have a channel in the #1260967323674742854, you'll create a team tomorrow.

minor cape
#

not quite hahaha

radiant cliff
#

I think this library can benefit from adding functionalities present in LoggerPro, which is the software that alot of academic institutions use. For starters, linear and curve fit, correlation and RSME values, error bars, calculating coefficients of the fit equation used etc

#

and graphing the integral as well

minor cape
#

Hi @radiant cliff , it sounds like this would be more suitable for a separate package that deals with data preparation and manipulation.

For more complex computations on large data sets, Typst might also not be the tool of choice. In this case, I recommend preparing the data somewhere else (R, Python, data analysis software), exporting the results, and importing them into Typst for plotting.

warm ruin
#

@minor cape

For more complex computations on large data sets, Typst might also not be the tool of choice. In this case, I recommend preparing the data somewhere else (R, Python, data analysis software), exporting the results, and importing them into Typst for plotting.
Can you elaborate on that. I am considering typst for processing the results of statistical experiments. Where I am planing to feed raw data (CSV) into typst and do processing (aggregation and statistical computations).

minor cape
#

Hi @warm ruin !

Sure, I'm also planning to add a tutorial on that to the documentation.

Now you can either do the processing in Typst. This can be great, if

  • you wish to do everything in one program,
  • the data set is not huge (like 1m points is probably too much),
  • and the computation is not too heavy.

Otherwise, you could process your data elsewhere. I don't know your background, but you might use a statistical tool or programming language to generate data that you can plot directly.

You would then export the processed data (e.g., filtered, accumulated or whatever) to a CSV or (maybe even better) JSON file that you can now import in Typst. For this I recommend using the built-in csv or json functions or in the case of CSV lq.load-txt which is more powerful and can also do the string-to-number conversion for you.

Now you could directly plot the data imported form the CSV with no or just little processing on the Typst side.

#

The thing is also that there are basically no Typst packages for data processing yet, so you would need to do everything by hand. For example I'm not aware of a package that can compute correlations or Fourier transforms. This is why an external tool for the preprocessing might be better.