intel / p3-analysis-library

A library simplifying the collection and interpretation of P3 data.
https://intel.github.io/p3-analysis-library/
MIT License
7 stars 10 forks source link

Adds a new backend for generating plots using TeX/PGFPlots #18

Closed swright87 closed 4 months ago

swright87 commented 1 year ago

Proposed changes

This PR adds a new backend that generates TeX files that contain code to build cascade plots and navigation charts using PGFPlots.

Some of the customisations available in the MatPlotLib backend are still available within this implementation; however, the main motivation behind this is that the output can be infinitely modified with anything PGFPlots compliant. The data can also be easily updated in the future without using the library.

swright87 commented 1 year ago

For reference, the two attachments here were generated using the library, one using matplotlib, one using the TeX engine (though the LaTeX needs to be edited to escape the % symbols in the application names!).

cascade-mpl.pdf cascade-tex.pdf

swright87 commented 5 months ago

@laserkelvin : There seems to be an issue in compatibility between black and flake8.

Initially I was failing the checks because black thought everything was fine, but flake8 suggested that black would make a change. I updated my local installs, and then black did make a change. But now black on the CI system indicates that it prefers how it was previously.

swright87 commented 5 months ago

Updated to include PGFPlot generated NavCharts too.

See: navchart.pdf

Pennycook commented 5 months ago

I closed and re-opened in an attempt to re-trigger the CI. What I'm seeing is that the old format test failed. I don't understand why they're still relevant. Any idea, @laserkelvin?

laserkelvin commented 5 months ago

Yeah I have no idea why that is the case...

swright87 commented 4 months ago

The backend has been reworked using the structure from the current main repo. All previous commits have been squashed into a single commit.

Primary change

A new backend has been added that uses TeX/pgfplots to build TeX cascade and navchart plots.

This uses jinja2 to generate TeX from some templates.

Other changes

Pennycook commented 4 months ago

Thanks, @swright87. I think this looks good to merge now. I fixed a few things I noticed on re-review, and rebased on top of main to fix the conflicts.

Now that the functionality is finished, we also need some tests and examples. These could be the same thing (see #37).

swright87 commented 4 months ago

EDIT: Oh, it's because there are "%" symbols in the labels, which are interpreted as TeX comments. I don't know enough about jinja to know how to escape them, though.

I started to fix this in Python, but it seems the easiest (and perhaps least error prone) fix is to put the escaping directly in to the Jinja templates. It should escape all of the potentially problematic characters in LaTeX (#, %, $, ^, etc.).