Skip to content

Visualizing Data

We export a number of files that you can use to visualize and analyze your simulation and optimization results locally.

Mesh .parquet .csv

Section titled “Mesh ”

TBD.

Contacts .parquet .csv

Section titled “Contacts ”

TBD.

TBD.

This file is available in .csv format, and contains data required for plotting the quality of a 3D print.

The example below shows how to use this file to generate an interactive 3D plot of the quality:

  1. Ensure dependencies

    #!/bin/bash
    uv init
    uv add polars plotly
  2. Import dependencies

    from typing import List
    from dataclasses import dataclass
    import plotly.graph_objects as go
    import polars as pl
  3. Load plot data and group by group

    df = pl.read_csv("plot.csv")
    df = df.rename({"meshIndex": "mesh_index"}) # Convenience using snake case
    grouped_df = df.group_by("group")
  4. Write a convenience function to produce correct colors

    @dataclass
    class Color:
    r: float
    g: float
    b: float
    def get_gradient_rgb(raw_value: float | None) -> Color:
    if raw_value == None:
    return Color(r=0, g=0, b=0)
    clamped_value = max(-1, min(1, raw_value))
    if clamped_value <= 0:
    t = clamped_value + 1
    return Color(r=0, g=round(t * 255), b=round((1 - t) * 255))
    else:
    t = clamped_value
    return Color(r=round(t * 255), g=round((1 - t) * 255), b=0)
  5. Iterate over the data & produce lines for the plot

    lines: List[go.Scatter3d] = []
    for group_id, group_data in grouped_df:
    shifted_group_data = group_data.shift(-1)
    for previous_row, row in zip(group_data.iter_rows(named=True), shifted_group_data.iter_rows(named=True)):
    color = get_gradient_rgb(previous_row["quality"])
    line = go.Scatter3d(
    x=[previous_row["x"], row["x"]],
    y=[previous_row["y"], row["y"]],
    z=[previous_row["z"], row["z"]],
    mode="lines",
    line=dict(color=f"rgb({color.r},{color.g},{color.b})", width=5),
    )
    lines.append(line)
  6. Plot the data

    layout = go.Layout(
    scene=dict(
    xaxis_title="X Axis",
    yaxis_title="Y Axis",
    zaxis_title="Z Axis",
    aspectmode="data"
    ),
    showlegend=False
    )
    fig = go.Figure(data=lines, layout=layout)
    fig.show()
  7. View the result

    The browser should open and display an interactive 3D plot:

    Example 3D plot visualization

Many of our exported files are available in Apache Parquet format for efficient data processing. For more information about Parquet files and how to work with them, see the Data Formats guide.