fluprodia icon indicating copy to clipboard operation
fluprodia copied to clipboard

Add more flexibility with isolines label

Open cagocagette opened this issue 1 year ago • 2 comments

I'm quite new to fluprodia but I'm already loving it.

However, I noticed it's missing flexibility for the isolines labels. In particular :

  • it would be interesting to be able to label 1 isoline out of 2 (or out of 4) to free up some space in the graph
  • the label of the isentropic and in particular the unit displayed (\frac{kJ}{kgK}) takes way to much space and makes the plot very messy To illustrate these two points, I'm joining a (logP,h) diagram I made with fluprodia.

I believe these two additions to fluprodia would make the diagrams look much nicer.

logph_diagram.pdf

cagocagette avatar Dec 20 '24 19:12 cagocagette

Hi @cagocagette,

I'm quite new to fluprodia but I'm already loving it.

Nice to hear that and thank you for your suggestions, I think the number of labels per line is a very good idea. What would you suggest for the display of fractions? Something like just having J/kgK?

Best

Francesco

fwitte avatar Dec 21 '24 12:12 fwitte

This could be a possible API, what do you think:

from fluprodia import FluidPropertyDiagram
from matplotlib import pyplot as plt
import numpy as np


diagram = FluidPropertyDiagram("NH3")
diagram.set_isolines_subcritical(T_min=250, T_max=450)
diagram.calc_isolines()

fig, ax = plt.subplots()

isoline_data = {
    "Q": {
        "values": np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0]),
        "label_every_nth": 5,
        "labels_per_line": 3
    }
}
diagram.draw_isolines(fig, ax, "Ts", 0, 7000, 250, 450, isoline_data=isoline_data, latex_units=False)
plt.show()

You can test it with the branch of PR #18

Only issue right now seems to be, that for log-spaced points in the data used to create the diagram the label positioning looks a little bit off, because the labels are distributed linearly over the points available within the range of the isoline... I am not sure whether it is worth the overhead in the back-end to keep track, which lines are based on what spacing in the data to then distribute the labels per line visually pleasing.

I would be happy with a short feedback :).

grafik

fwitte avatar Dec 21 '24 13:12 fwitte