Closed waldyrious closed 10 years ago
Ah, I just remembered where I had read about the conversion of decimal numbers to fractions. Seems like it wouldn't be hard to implement, by passing an adaptive tolerance parameter.
I think doing this would require converting to a macro, because all I get in the plot function is a floating-point number (I can't know that you originally typed 6pi). With a macro I could parse the arguments symbolically. This would add a decent bit of complexity to the code. It does already try to round intelligently based on the available digits with the specified margin width.
Fair enough. But even without knowing what the user typed, I suppose the rounding could be improved, particularly for the y axis. One suggestion is to use a reasonable threshold as I suggested above (1/100th of the covered range or something to that effect), but I'm sure other heuristics can be devised.
If something like that is implemented, I'd then suggest deprecating the margin
option, which, apart from the rounding, doesn't seem otherwise as relevant/necessary as the other sizing options.
Good point on the relative scale; I'll look into that. The margin option is staying, because it's necessary to allow users to make multiple plots that all fit in the same exact output dimensions.
On September 14, 2014 8:57:20 PM Waldir Pimenta notifications@github.com wrote:
Fair enough. But even without knowing what the user typed, I suppose the rounding could be improved, particularly for the y axis. One suggestion is to use a reasonable threshold as I suggested above (1/100th of the covered range or something to that effect), but I'm sure other heuristics can be devised.
If something like that is implemented, I'd then suggest deprecating the
margin
option, which, apart from the rounding, doesn't seem otherwise as relevant/necessary as the other sizing options.
Reply to this email directly or view it on GitHub: https://github.com/sunetos/TextPlots.jl/issues/5#issuecomment-55545399
I see. In that case, it perhaps wouldn't hurt making that suggestion in the README examples involving the margin option. Currently, the only mention of an use/effect of the margin option is the rounding, which may be misleading, especially if another rounding method is implemented.
I've added a decent number of attempts at smarter formatting of the axis limits. As for the documentation on the options, I will expand that when it's clear there are more users of this library.
In the x axis, if I pass, say,
6pi
I'd like to see that in the graph, not 18.8495 as seen here.In the y axis, there should probably be some threshold for rounding (say, 1/100th of the covered range), so instead of -0.99899 to 0.99899 (see the example linked above), TextPlots would use -1 to 1. Even better if it applies the threshold to approximate known constants like e, sqrt(2), simple fractions, etc. -- but that's probably wishful thinking for now :)