Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[] Feature request: Horizontal guide lines in plots #2482

Closed
cool-RR opened this issue Aug 1, 2024 · 10 comments · May be fixed by #2489
Closed

[] Feature request: Horizontal guide lines in plots #2482

cool-RR opened this issue Aug 1, 2024 · 10 comments · May be fixed by #2489

Comments

@cool-RR
Copy link
Contributor

cool-RR commented Aug 1, 2024

It would be cool if I could add horizontal guide to plot. I mean that I could give specific Y values where a line would be drawn from the left edge of the screen to the right edge. Whereever there are datapoints, the line won't be drawn.

Here's a grab-bag of horizontal line characters at various heights:

━─═﹉﹊﹋﹌﹍﹎﹏―—–‐⁃_‗⎯⎼⎽⏤▁▔⚊一

We could use the different heights to make the lines more accurately-placed.

@midichef
Copy link
Contributor

midichef commented Aug 5, 2024

I've got this mostly implemented. I'm using these characters ▁━▔, since I don't know of any other Unicode characters for horizontal lines that have vertical levels that I can rely on.

How do you want to specify the y values? From the command line, in .visidatarc, or interactively within visidata?

@cool-RR
Copy link
Contributor Author

cool-RR commented Aug 6, 2024

Awesome, thank you! I was thinking there'd be an attribute like graph_sheet.y_guide_lines = [0, 0.5, 1] and then commands to add or remove numbers to that list. Then I could also write a script in .visidatarc that automatically adds guide lines by just adding to that list.

@midichef
Copy link
Contributor

midichef commented Aug 6, 2024

Okay I've got it implemented, @cool-RR. Let me know what you think of #2489.

While working on this feature, I fixed some bugs in how points line up with labels. They became very obvious in graphs with lines drawn on them. So you will also want to deploy the fixes in #2487.

@cool-RR
Copy link
Contributor Author

cool-RR commented Aug 6, 2024

Awesome, thank you! What would be the way for me to test this feature, given that it depends on two commits in separate branches?

@midichef
Copy link
Contributor

midichef commented Aug 6, 2024

Try this, for pip:

cd /tmp
git clone -v -v https://github.com/midichef/visidata/ visidata.midichef
cd visidata.midichef
git cherry-pick origin/graph_plot_points origin/graph_line
pip install file://`pwd`
## to reinstall the main branch afterward
# pip uninstall visidata; pip install git+https://github.com/saulpw/visidata

If it worked, you'll be able run vd, then press Space and run add-line-y, remove-line-y, clear-lines-y interactively. I'm not yet sure how to preset line values in .visidatarc.

@cool-RR
Copy link
Contributor Author

cool-RR commented Aug 6, 2024

Thank you, I'll do that soon. Note that you used the term "line" which might be a little generic and overloaded. I asked Claude and ChatGPT what you might call a line like that which doesn't represent real data, and they suggested "baseline", "reference line", "threshold line", "benchmark line", "target line" and "cutoff line". I like the first two suggestions best. Also if this is accepted there's also a good chance that the same feature for the X axis would be desired.

I'll test in the next few days and let you know.

@midichef
Copy link
Contributor

midichef commented Aug 6, 2024

Thanks for suggesting alternatives! I agree "line" is too generic, and I like "reference ilne". Maybe change add-line-* to add-refline-*?

Vertical lines on the X axis are already supported, the *-y commands have counterparts in add-line-x, remove-line-x, and clear-lines-x.

@midichef
Copy link
Contributor

midichef commented Aug 7, 2024

The develop branch has merged the patch fixing alignment between points and labels. So I've deleted the branch I used for that pull request.

Now the commands to try the graph reference-line feature are:

cd /tmp
git clone https://github.com/midichef/visidata/ visidata.midichef
cd visidata.midichef
git cherry-pick origin/graph_line
pip install file://`pwd`
## to reinstall the main branch afterward
# pip uninstall visidata; pip install git+https://github.com/saulpw/visidata

@cool-RR
Copy link
Contributor Author

cool-RR commented Aug 8, 2024

I tried it now and it looks good.

When I first did a line it looked great:

screenshot_TURING_2024-08-08_095800

This is just the right thickness and color I imagined. I see it uses the character

However, after I pressed x and changed xmin xmax, the line became thicker and possibly have a different color:

screenshot_TURING_2024-08-08_095744

This uses the character . I don't like how it looks.

I tried clear-lines-y and it worked.

I tried add-line-x and got this:

screenshot_TURING_2024-08-08_095952

Like the previous example, the line is too bold.

Otherwise the feature is great.

@midichef
Copy link
Contributor

@cool-RR
The newest commit on #2489 changes the line characters based on your feedback. The y-line characters are now ▔──▁. Unfortunately I can't find a mid-cell horizontal character in Unicode that is guaranteed to be the same width as the ones at the top/bottom. I've chosen to exclude characters that have tiny visual spaces between characters, like dashes in many fonts: "---". I only looked at characters that leave no visual blank spots between repeated characters, as in your sample images.

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants