-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Adding automargin support to plot titles #6428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
68c6165
ad6eb00
0826ddd
45d9cbf
c6e31be
f46014f
587dfcb
3dae109
61487a8
8679e7d
e8e49a5
2b59e2c
5e4ab42
4bb109e
7ce1234
b274642
cc15ff6
938d52d
75636e2
b7e3295
04f8825
ad202d9
9611672
c4d1076
21a9e59
78cecff
fd111d5
2a47c00
52b37c0
4322c7b
73ccaf4
a3462d2
33bbbef
9af5cbd
67cf8da
16c0bcf
17c3244
c014702
e59b18f
ddaf013
de7ca48
e77126c
26ca553
e5e8a2a
d70fb46
616057f
3523406
90bd374
158791f
c4e706e
087c162
c4d75d4
a257836
662628e
e4b5f29
3dcaab8
2a0011a
a8185f4
0c0e47e
7f89c73
132c57b
7d4e352
ad7c6f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -18,11 +18,14 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| "height": 300, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "width": 400, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "margin": {"t":0, "b": 0, "l": 0, "r": 0}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "xaxis": {"automargin": true, "title": {"text": "x-axis title", "standoff": 0}}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var isInside = insideTicklabelposition(ax); | |
| if(ax.type === 'multicategory') { | |
| titleStandoff = ax._depth; | |
| } else { | |
| var offsetBase = 1.5 * fontSize; | |
| if(isInside) { | |
| offsetBase = 0.5 * fontSize; | |
| if(ax.ticks === 'outside') { | |
| offsetBase += ax.ticklen; | |
| } | |
| } | |
| titleStandoff = 10 + offsetBase + (ax.linewidth ? ax.linewidth - 1 : 0); | |
| } | |
| if(!isInside) { | |
| if(axLetter === 'x') { | |
| titleStandoff += ax.side === 'top' ? | |
| fontSize * (ax.showticklabels ? 1 : 0) : | |
| fontSize * (ax.showticklabels ? 1.5 : 0.5); | |
| } else { | |
| titleStandoff += ax.side === 'right' ? | |
| fontSize * (ax.showticklabels ? 1 : 0.5) : | |
| fontSize * (ax.showticklabels ? 0.5 : 0); | |
| } | |
| } |
The ideal solution would be put all that logic into title.standoff in supplyDefaults, rather than at the draw step.
BTW @archmoj I notice standoff is incorrect for multicategory axes with side: 'top'... didn't look at left or right but I bet one of those is incorrect too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking into this block as well but it's not clear to me how a change in margin size impacts the standoff value. By my reading, it's only the font size and axis properties (like tick length and line width) that we're looking at here. I could be missing something obvious since I've been staring at this block for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look to scootTitle function in main Titles.draw
Uh oh!
There was an error while loading. Please reload this page.