Menu

#576 Unique with first/last [5.4.4 on Debian Bookworm. Wish]

None
open
nobody
wish (1)
None
5 days ago
7 days ago
Anonymous
No

It would be nice to have more options for the 'smooth unique' function. I would especially like something like 'smooth unique-first' that would take the first of the values for the same X coordinate, and maybe also corresponding -last, and -min and -max.

My use case is plotting my personal budget, which I would like to plot as a detailed line for every day, but for yearly graphs I would like to plot just the first value for each month.

I know I can hack this with filtering the data when reading it, but it is a bit messy.

Discussion

  • Ethan Merritt

    Ethan Merritt - 6 days ago

    I understand the reason for your request, and I think it's reasonable. But I do want to point out that basing it on "smooth unique" may not be quite what you want, since that option sorts the points on x as a first step and does not guarantee that the "first" or "last" property is retained after sorting. That depends on what algorithm the C library qsort() routine on your system uses. Some systems provide a stable sort algorithm (preserves initial order of equal key values); others do not.

    The development version of gnuplot adds a check at build time that tries to determine if the library's sort routine has this behavior or not, and if not it adds fix-up code locally in gnuplot to make the sort stable. But this is relatively untested and so far "smooth" is not one of the places where local fix-up code is added. That doesn't matter for "smooth unique" per se since the average is not affected. But if nothing else, your request highlights the fact that other "smooth" options, or future options, may indeed care.

     
  • Ethan Merritt

    Ethan Merritt - 5 days ago

    Ticket moved from /p/gnuplot/bugs/2730/

    Can't be converted:

    • _milestone:
    • _priority:
     

Log in to post a comment.