Repository navigation
domainpad: pixel spacing inside axis domains - #7965
SharadhNaidu wants to merge 13 commits into
Conversation
`domain` is a plot fraction, so the gap it leaves between subplots grows and shrinks with the figure while a subplot title does not. domainpad reserves a fixed number of pixels inside the domain edges instead, resolved at draw time. Applied in ax.setScale to _offset and _length rather than to ax.domain, so the domain keeps meaning what the user typed and anything referenced to `<axis> domain` follows the padded area without new drawing code. Along with it: - scattergl, splom and the rangeslider rebuilt the plot rect from `domain` and so did not see the pad; they now read _offset and _length - pads that do not fit are backed off together, since setScale already throws on a negative length - updateDomain scales the padded length rather than the raw span, so a scaleanchor ratio stays exact when the constraint shrinks a padded axis Refs plotly#7835
Removed attribution from the commit message.
The three places that build the plot rect from `domain` were changed to read _offset and _length instead. That round trips through pixel space, and the result is not exactly the value it started from: splom cell domains came back about one ulp out, which moved rasterised markers enough to fail the splom_*-nodiag image baselines even though no padding was involved. Add the resolved padding to the original expressions instead, and expose it as ax._padStart / ax._padEnd for those callers. Adding a literal zero is exact, so an unpadded plot now produces the same numbers it always did. Also list domainpad in swapAxisGroup's noSwapAttrs, next to domain: its keys are named for screen edges, so swapping x and y would need them remapped.
|
@emilykl apologies if i am violating any principles by directly tagging you , but could we close this issue ? |
|
any updates on this PR ? |
Sorry that this got dropped. What issue are you asking to close? |
|
oh my bad i meant the PR and the issue i am talking about is #7835 . |
|
You want to close the PR? |
|
no,sorry for the confusion , I don't want to close it. I meant i would like the PR to be reviewed so that , once it's merged, it closes #7835. I'm also pushing a few updates today the regenerated TypeScript types that the generated types drift check is flagging, a fix so spikemode 'across' spikes stop at the padded plot area , tests for the scattergl and splom code paths , and an image mock. I'll update the description when that's in. the API questions at the bottom are still the main thing it would help if i get a input on. |
|
Understood. I'll check with my team and follow up with you. |
|
thanks mate! |
updateDomain multiplied the domain by (newSpan / inputSpan). Without padding, that ratio is 1 / factor, but the multiply can change the last bit of the result, so a plot with no domainpad could move by a tiny amount. Divide by `factor` as main does, and change the divisor only when the axis has padding. Without domainpad, the result is now the same as on main.
… and types The comments and attribute descriptions now follow the Simplified Technical English rules in AGENTS.md. Lines that this PR touches now use const, let and arrow functions. There is no change in behavior. The regenerated schema.d.ts and plot-schema.json fix the generated-types-drift check, which failed because the types did not include domainpad.
Spikes with spikemode 'across' got their span from the counter axis domains, so with domainpad they crossed the reserved space, for example a subplot title. Get the span from the domain minus the padding of each counter axis. Without domainpad the span is the same as before. A free axis still extends the span to its position. The new test fails without this fix.
scattergl and splom build their regl viewports from `domain`, so they add the padding in their own code. These tests make sure that the viewport, the splom cells and the regl grid match the padded plot area.
The mock shows four subplots with different domainpad sides, so a change in the padded plot area shows in the image tests. The baseline image must come from the baselines-default-diff CI artifact.
An earlier commit removed the "with thanks to" credit by mistake. The draftlog convention includes it.
# Conflicts: # test/jasmine/tests/hover_spikeline_test.js
adds
domainpadto cartesian axes: space in pixels inside the edges ofdomain. closes #7835, and gives plotly/plotly.py#5606 the attribute that it needs.why
domainis a fraction of the plot area, so the gap between stacked subplots changes with the figure size. a subplot title has a fixed height in pixels. on a short figure, the title overlaps the subplot above. plotly.py cannot fix this, becausemake_subplotsdoes not know the rendered height.this follows approach a from #7835 (comment):
how
ax.setScale()takes the padding from_offsetand_length.ax.domainkeeps the user value._offsetand_lengthfollows the padding with no change: the plot area, axis lines, gridlines, clip paths, dragboxes, and<axis> domainreferences.leftandright. y axes coercetopandbottom. overlaying axes use the padding of the axis under them.doAutoMarginuses the same method for margins.scaleanchorandconstrain: 'domain',updateDomainscales only the unpadded part of the span. thus the scale ratio stays exact.these places build the plot rect from
domain, so they now add the padding:scatterglviewportsplomcells and the regl gridspikemode: 'across', which now stop at the plot area and do not cross a titlewith no
domainpad, all output is the same as before, to the last bit.scope
cartesian axes only. polar, ternary, geo, map, smith and the domain traces convert their domains in their own code. plotly/plotly.py#5606 needs only cartesian axes. paper-referenced items, such as the legend, the rangeselector and
xref: 'paper'annotations, do not move.tests
axes:axis domainpadcovers defaults, coercion, each side, the clamp, overlaying axes, constraints, the rangeslider, many axis types, and the no-op casehover_spikeline: 'across' spikes stop at the padded plot area. this test fails without the fix.scattergl: the regl viewport matches the padded plot areasplom: the cells and the regl grid match the padded plot areasaxes_domainpad. the baseline must come from thebaselines-default-diffci artifact.questions
domainis no longer the only input to the plot rect. the alternative is to fold the padding intoax.domainat draw time. that change would leave scattergl and splom alone, butfullLayoutwould then show padded domain values. do you prefer that approach?layout_attributes.js, so the schema shows all four keys on the two axis letters. each axis coerces only its two keys. do you prefer separate attribute objects?