saulpw / visidata

A terminal spreadsheet multitool for discovering and arranging data
http://visidata.org
GNU General Public License v3.0
7.88k stars 279 forks source link

Feature request: Optional zero-based numbering for plots #1836

Closed cool-RR closed 1 year ago

cool-RR commented 1 year ago

I wish there was an option to start numbering for multi-column plots at 0. I've got columns like "agent_0", "agent_1", "agent_2" and it's quite frustrating to see them mapped to 1, 2 and 3.

saulpw commented 1 year ago

Do you mean the legend keys that enable/disable certain colors? . I've been frustrated by this too, sometimes I even rearrange the rows so the mapping makes more sense (they are assigned in the order they appear in the data). Maybe if a shortcut appears in a column name, it could be assigned that way? In any event, needs some design.

Kondo'ed for now.

cool-RR commented 1 year ago

I do mean the legend keys. What you propose is cool, but for starters I imagined a simpler solution: An option plot_labels_start_at_zero that defaults to False. It's possible that I have a volunteer who might implement this, and hopefully might work on other features and bugs later.

saulpw commented 1 year ago

I'm not sure about the plot_labels_start_at_zero option, but I'd love to chat with this volunteer, and see if we can't get something that works for you.

cool-RR commented 1 year ago

My personal workaround if it helps:

# Monkeypatch to start legends at 0 rather than 1:
def plotlegends(self):
    from visidata.canvas import colors
    # display labels
    for i, (legend, attr) in enumerate(self.legends.items()):
        self.addCommand(str(i), 'toggle-%s'%(i),
                        'hideAttr(%s, %s not in hiddenAttrs)' % (attr, attr),
                        'toggle display of "%s"' % legend)
        if attr in self.hiddenAttrs:
            attr = colors.color_graph_hidden
        self.plotlegend(i, '%s:%s'%(i,legend), attr, width=self.legendwidth+4)

visidata.Canvas.plotlegends = plotlegends