plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Set marker size in data coordinates, not just pixels

Open molehillrocker opened this issue 9 years ago • 5 comments

At the moment we use symbols to display some kind of "measurement threshold" for a couple of grouped bar charts. This looks nice in the first place, since the symbols are as wide as the bars. However when the user zooms in, the bar groups are scaled but the symbols remain as wide as before, leading to the effect that is shown in the attached screenshot.

image

We also tried to use a separate trace that renders as line (lines+markers), but we didn't make it to draw it dashed in a way that each dash spans a single bar group and each gap between two bar groups remains empty (see next screenshot).

image

It would be nice if this could be achieved by either using symbols (a line in our case) that automatically stretches horizontally, or use lines+markers with gaps (and thus no interconnection between the markers, something like the hvh line shape seen here without the vertical sections.

molehillrocker avatar Oct 25 '17 14:10 molehillrocker

If this is a numeric x axis you should be able to get what you want by adding null or '' between the segments

{
    x: [0.6, 1.4, null, 1.6, 2.4, null, 2.6, 3.4],
    y: [65, 65, null, 20, 20, null, 50, 50],
    mode: 'lines'
}

That won't extend to categorical axes though (see also https://github.com/plotly/plotly.js/issues/2004) and I can see various other uses for markers that scale with the data axes, so it's definitely a feature worth considering.

alexcjohnson avatar Oct 25 '17 18:10 alexcjohnson

In most charts we actually use numerical axes, so I think I'll try your approach, since it looks very promising. :)

molehillrocker avatar Oct 26 '17 17:10 molehillrocker

I got it to work with the mentioned workaround, thanks a lot. Should I close this issue or do you want to keep it open as a feature request?

molehillrocker avatar Nov 03 '17 12:11 molehillrocker

It's an interesting idea, not one we'll be working on in the near future but worth keeping open.

alexcjohnson avatar Nov 03 '17 13:11 alexcjohnson

Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson

gvwilson avatar Jun 10 '24 17:06 gvwilson