sunetos / TextPlots.jl

Fancy terminal plotting for Julia using Braille characters.
MIT License
45 stars 11 forks source link

Gridlines and inverted mode #4

Closed z-m-k closed 10 years ago

z-m-k commented 10 years ago

Two switches in the plot() function which allow to:

It comes in handy if Braille blank, 0x2800, has different width than the remaining characters in the range.

Example without gridlines: image

Example with gridlines: image

waldyrious commented 10 years ago

I wonder if there is another way to workaround the inconsistent width of the Braille blank without using the gridlines. Maybe one of these consistently matches the proper width?

sunetos commented 10 years ago

In a monospaced font, when would the width ever be inconsistent? What font are you using? I think it's safe to say that TextPlots is pretty dependent on a monospaced font.

z-m-k commented 10 years ago

Source Code Pro/Consolas. I think it is a Windows thing, though.

sunetos commented 10 years ago

Even the regular space character is sized incorrectly in your screenshots: the axis label (max x value) in the bottom-right is normally right-aligned with the edge of the graph, but it extends further right in your screenshot. I'm not sure how that's possible with a monospaced font.

sunetos commented 10 years ago

Either way, thanks for the pull request! I can't see any reason not to support these parameters. I hope you don't mind that I rewrote it to be quite a bit shorter, and fixed 2 bugs I found:

  1. Combining invert=true, gridlines=true wasn't an exact inversion of invert=false, gridlines = true (the gridline was in a different place).
  2. Since you were setting the char each time in showdot() instead of bitwise ORing, it failed when plotting multiple Y values with the same X value.

I will update the version in METADATA.jl in a day or so with this addition after making sure no bugs pop up. You can test it with Pkg.clone("https://github.com/sunetos/TextPlots.jl/").

z-m-k commented 10 years ago

Nice. I will admit it took me some time to actually figure out what is going on there, and since I assumed this might be localized to my machine only, it felt stupid just to complain something is not working without proposing a way to fix it. It does feel silly how little you changed compared to the original code to get the same/better effect than after what I did.