How to plot 3D data?

Hi Guys,

Is there any ongoing project on 3D plots in Typst? I believe this feature would be very amazing.

For latex, there are tiki and pgfplots, and I would like to find alternatives of them in Typst.

You are probably looking for surface plots in 3d but for anyone that is just looking for a way to draw other 3d objects, cetz supports (x,y,z) coordinates:

2 Likes

Hello @robinDrone, I have renamed your post to “How to plot 3D data?”. If that’s not your topic, please modify it accordingly! I also moved it to the Questions category :smiley:

1 Like

There has been a recent show case on Discord (not mine):

Example from the README:

#import "@preview/plotsy-3d:0.1.0": *

#let size = 5
#let scale_factor = 0.3x
#let (xscale,yscale,zscale) = (0.3,0.3,0.05)

#let func(x,y) = y*calc.sin(x) -x*calc.cos(y) 
#let color_func(x, y, z, x_lo,x_hi,y_lo,y_hi,z_lo,z_hi) = {
  return purple.transparentize(20%).darken((z/(z_hi - z_lo)) * 300%)
}
// for all options see the library file
#plot_3d_surface(
    func,
    color_func: color_func,
    subdivisions: 5,
    subdivision_mode: "increase",
    scale_dim: (xscale*scale_factor,yscale*scale_factor, zscale*scale_factor),
    xdomain: (-size,size), // plotting domain
    ydomain:  (-size,size), // plotting domain
    pad_high: (0,0,2), // increase axis size higher than domain 
    pad_low: (0,0,0), // increase axis size lower than domain 
    axis_label_offset: (0.2,0.1,0.1), // move the x y z further from axis
    axis_text_offset: 0.045, // move the numbers further from axis
)
2 Likes