Resolve mark vs. axis alignment offset.
See original GitHub issueWhen I display the following spec:
{
"encoding": {
"x": {
"field": "a",
"type": "quantitative"
},
"y": {
"field": "b",
"type": "quantitative"
}
},
"data": {
"values": [
{
"b": 2,
"a": 2
},
{
"b": 1,
"a": 1
}
]
},
"mark": "point"
}
And then zoom into it, I see that the point isn’t really centered on the grid lines:
is a zoomed version of the middle point.
I’m using the SVG renderer, and then of course the same happens if I convert to PNG, PDF etc.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
How-To: X/Y Offset - Carlson Design
We then need to make sure our Z-axis is properly aligned. Do this by standing directly in front of the cutting head and...
Read more >Offset alignment in CMM software
A cmm programmer can easily figure out that the angle offset from datum C hole to the main axis is 42.338645 deg. (or...
Read more >Axis | Vega-Lite
By default, axes are translated by a 0.5 pixel offset for both the x and y coordinates in order to align stroked lines...
Read more >Ender 3 alignment: problems and solutions - YouTube
Walkthrough of the various issues with adjusting the Creality3D Ender 3 printer. This vid includes several different methods, ...
Read more >How do I align gridlines for two y-axis scales using Matplotlib?
I could solve it by deactivating ax.grid(None) in one of the ... total tick marks ax1 and ax2 are matplotlib axes Spacing between...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@davidanthoff Thanks for sharing. This is a known, long-standing issue as @domoritz mentions. We just don’t (yet) happen to have a clean solution that doesn’t introduce other problems elsewhere. The issue is particularly salient with scalable vector graphics because when you zoom in, what used to be 0.5 pixel offset gets magnified. I’d certainly love to find a solution.
@kanitw what is the problem with the image you shared? Is it that the bars are not perfectly centered? (Keep in mind the time span for each bar is inclusive of its left gridline but not the right gridline…)
@kanitw: That sounds reasonable for many cases, but likely fails as a general rule if the spans get much larger or smaller. In your case the gridlines are stroked (centered between pixels by default) and the bars are filled (pixel aligned by default), so I believe our offset is actually making the alignment better (not worse), by snapping lines to proper pixels. I think the lack of centering arises due to the left-inclusive / right-exclusive span, which should be mathematically correct.
I’ll keep the issue focused on the point / grid alignment issue @davidanthoff raises. In the worst case, I could imagine adding config to control the offset, which at least might be useful for exported images, etc.