Tk Library Source Code

View Ticket
Login
Ticket UUID: 009b09029f4d775defd6365dc63e8be30e7aea95
Title: Axis labels are not always "nice"
Type: Bug Version: 1.6.1
Submitter: arjenmarkus Created on: 2022-01-26 07:12:12
Subsystem: tklib :: plotchart Assigned To: arjenmarkus
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-11-16 17:17:33
Resolution: None Closed By: nobody
    Closed on:
Description:
Nick Matthews noticed that an axis defined as 121.45 - 121.51 with step 0.02, but also one defined as 0.0 - 2.0 with step 0.2 may produce awkward labels: 121.49999999 for instance. The issue is solved when using a number format like %12g.

Indeed, Tcl will format [expr {121.49+0.02}] as 121.50999999999999. The main issue is that it is esthetically messy. Perhaps the default format should be changed.
User Comments: serhiy.storchaka added on 2026-11-16 17:17:33:

I could not reproduce the case from the ticket, but on reversed axes zero was shown as 2.77555756156e-16, and the labels of polar plots were not formatted. Proposed fix in branch plotchart-zero-labels.


aku added on 2022-05-10 09:28:42:

@arjen Was this possibly fixed by Dadalau's work, i.e. [a8df88b4058511b0] ?