question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

explicit bar positioning and width

See original GitHub issue

There are a number of use cases for explicit control over bar widths and positions (horizontal and vertical). I’m thinking about this in the context of waterfall plots, irregular-width bars but also times when the auto width is wrong (eg bar positions 1, 3, 5 and you want width 1, not width 2…), complex groupings (a stack of several traces, grouped with another stack of several other traces, etc).

If we allow explicit position and size, that covers every degree of freedom that exists for drawing bars on a plot. Then later we can peel off pieces with more meaning (like complex groupings that we should be able to describe in terms of grouping and stacking rather than positioning), and provide a simpler syntax for those.

I’m thinking of attributes:

// width of bars, in units of the position axis data
// This would override the whole automatic width machinery,
// including bargap and bargroupgap
width: {
    valType: 'number',
    min: 0,
    arrayOk: true
},
// shift on the position axis, in units of the position axis data
// This would override the automatic positioning machinery
// in the case barmode='group', rather than add to it.
offset: {
    valType: 'number',
    arrayOk: true
}
// shift of the bottom of the bar on the size axis
// This would override the automatic stacking machinery,
// rather than add to it.
base: {
    valType: 'any'
    arrayOk: true
}

Are offset and base clear enough? Any better names? And is width OK even for horizontal bars (in which case it’s really the bar height)?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:21 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
alexcjohnsoncommented, Aug 31, 2017

@AdnanBoota you might just need layout.bargap

Plotly.newPlot(gd, [{
    x: ['2017-01-02', '2017-01-03', '2017-01-04'],
    y: [2, 4, 3],
    type: 'bar'
}], {bargap: 0})

but if you really do need explicit widths on a date axis, you can specify them as milliseconds:

Plotly.newPlot(gd, [{
    x: ['2017-01-02', '2017-01-03', '2017-01-04'],
    y: [2, 4, 3],
    type: 'bar',
    width: 1000*3600*23 // 23 hours
}])
3reactions
etpinardcommented, Oct 25, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Positioning - Learn web development | MDN
Positioning allows you to take elements out of normal document flow and make them behave differently, for example, by sitting on top of...
Read more >
The same width of the bars in geom_bar(position = "dodge")
The width of the bars is dependent on numbers of observation in group given in variable C . I want to have each...
Read more >
Dodge overlapping objects side-to-side — position_dodge ...
position_dodge2() works with bars and rectangles, but is particulary useful for arranging box plots, which can have variable widths. Usage. position_dodge(width ...
Read more >
CSS Positioned Layout Module Level 3 - W3C
5.1. The Width of Absolutely-Positioned, Non-Replaced Elements. The constraint that determines the used values for these elements is:.
Read more >
Label Bars - NCL Graphics
lb_2.ncl: Vertical label bar and explicit labels. ... pmLabelBarOrthogonalPosF adjust the label bar position perpendicular to the main plot axis.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found