Skip to content

Improve pineappl plot Python interaction #249

@alecandido

Description

@alecandido

Currently, pineappl plot relies on Python and Matplotlib. This is actually quite nice, because people using PineAPPL are often familiar with Python, and know how to plot the information, once given.

A current mild pain-point is that there is a lot of string manipulation involved in the call, since a Python script is generated everytime, embedding the data:

print!(
include_str!("plot.py"),
inte = if bins == 1 { "" } else { "# " },
nint = if bins == 1 { "# " } else { "" },
pdfs = if pdfs == 1 || bins == 1 { "# " } else { "" },
xlabel = xlabel,
ylabel = ylabel,
xlog = xlog,
ylog = ylog,
title = title,
output = output.to_str().unwrap(),
data = data_string,
metadata = format_metadata(&vector),
);

However, dumping the script is a design featured, in such a way that people are able to customize it.

I see a few possible ways of improving:

  1. split the two pineappl plot operations: dump the script and the data separately (in a common data format, like CSV)
  2. leverage pineappl_py in the script, and directly extract the data from the grid (requires the installation of the PineAPPL python extension)
  3. move the plotting feature to pineappl_py itself (possibly with a pineappl-plot CLI, but it would be installed separately, at least until Distribute CLI as a Python package #176 will be completed)
  4. use PyO3 to make the call from the CLI (i.e. from Rust) - in this way people will be able to customize the script and pass it again, but there won't be any need of dumping the data any longer (most likely this is an overkill)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions