Menu

#590 Add cdot as multiplication sign

open
nobody
None
3
2025-06-11
2025-06-06
No

I suggest adding the · (cdot) symbol as the multiplication sign in tick labels for UTF-8 encoding. Currently, a cross symbol (×) is used for both the h and H modifiers. I implemented this change for myself by modifying src/util.c:

        } else switch (encoding) {
            case S_ENC_UTF8:

// strcpy(&tmp2[j], "\xc3\x97"); / UTF character '×' /
strcpy(&tmp2[j], "\xc2\xb7"); / UTF character '·' /

so now the command set format y '%h' can produce tick labels like "2·10⁵".

Discussion

  • Ethan Merritt

    Ethan Merritt - 2025-06-08

    Note that it is possible to do this by providing an explicit tick format.

    set ytics format "%.1t·10^{%.0t}"

    Since it may be difficult to type in the \cdot character on your keyboard, you can use an escape sequence.

    set ytics format "%.1t{\U+00B7}10^{%.0t}"

    But yes, it might be worth adding an option that is simpler to type.

     

    Last edit: Ethan Merritt 2025-06-08
    • Michael Okuntsov

      "providing an explicit tick format" - yes, but if you have a lot of auto-generated gnuplot scripts, you'll need an automatic format, something like "%g" (which the "h" modifier is doing, but with a cross), and you can't provide it for tick formatting.

       

      Last edit: Michael Okuntsov 2025-06-10
      • Ethan Merritt

        Ethan Merritt - 2025-06-11

        Sorry, I do not understand what you are saying. Why can't you provide it for tick formatting? If the script was previously saying "set tics format '%h'", you change the script to say instead "set tics format MYFORMAT" where MYFORMAT is any string you like. What have I missed?

        I do have a patch I am working on to add an alternative, but that wouldn't be available in a stable release for quite a while, so it would seem like a good thing to find a solution that works already and would provide an immediate broadly available option.

         
        • Michael Okuntsov

          Thanks for the reply. Here's my situation in brief:
          I generate gnuplot scripts automatically (via Python) for 50–1000 datasets with very different Y-axis ranges: from 0:10 to 1e5:5e20 or -1e-5:5e-5. I can't manually tune each script.
          Using set format y "%g" gives me inconsistent styles: for 0:10 I get nice integers,
          for large/small ranges I get 1e-5, 5e20, etc.
          However, my report format requires tick labels like:

          −1·10⁻⁵ or 1·10²⁰, not 1e-5.
          

          The %h format is almost perfect, but it uses a cross (×).
          What I’d really like is a format like %g, but with Unicode-friendly exponents instead of e notation. That way I don’t have to analyze each dataset just to pick the right format manually.

           
          • Ethan Merritt

            Ethan Merritt - 2025-06-11

            Hmm. If pdf output using the tikz terminal + pdflatex is an option for you, the format set tics format '$%H$' would do what you want. The LaTeX terminals use a cross for format %h and \cdot for format %H. One option I am looking at is to make the non-LaTeX terminals do the same.

             
            • Michael Okuntsov

              Thanks, but I'm using pngcairo to insert into MS Word.

               

              Last edit: Michael Okuntsov 2025-06-11

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.