|
7 | 7 | "source": [
|
8 | 8 | "# Configuring Nudge Units in Position Adjustments\n",
|
9 | 9 | "\n",
|
10 |
| - "The position adjustment `position_nudge()` now supports the `unit` parameter that specifies the measurement system for nudge offsets. <br/>\n", |
11 |
| - "Equivalent parameter is also available as `nudge_unit` in `geom_text()` and `geom_label()` directly. \n", |
| 10 | + "The position adjustment `positionNudge()` now supports the `unit` parameter that specifies the measurement system for nudge offsets. <br/>\n", |
| 11 | + "Equivalent parameter is also available as `nudgeUnit` in `geomText()` and `geomLabel()` directly. \n", |
12 | 12 | "\n",
|
13 | 13 | "Available Units:\n",
|
14 | 14 | "\n",
|
15 |
| - "- `'identity'` (default): nudge in data coordinates - a value of 1 corresponds to the distance from 0 to 1 on the axis\n", |
16 |
| - "- `'size'`: nudge relative to point size - a value of 1 corresponds to the diameter of a point with size 1\n", |
17 |
| - "- `'px'`: nudge in fixed pixels - a value of 1 corresponds to 1 pixel" |
| 15 | + "- `\"identity\"` (default): nudge in data coordinates - a value of 1 corresponds to the distance from 0 to 1 on the axis\n", |
| 16 | + "- `\"size\"`: nudge relative to point size - a value of 1 corresponds to the diameter of a point with size 1\n", |
| 17 | + "- `\"px\"`: nudge in fixed pixels - a value of 1 corresponds to 1 pixel" |
18 | 18 | ]
|
19 | 19 | },
|
20 | 20 | {
|
|
26 | 26 | {
|
27 | 27 | "data": {
|
28 | 28 | "text/html": [
|
29 |
| - " <div id=\"4DSxKL\"></div>\n", |
| 29 | + " <div id=\"JnN9cv\"></div>\n", |
30 | 30 | " <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
|
31 | 31 | " if(!window.letsPlotCallQueue) {\n",
|
32 | 32 | " window.letsPlotCallQueue = [];\n",
|
|
37 | 37 | " (function() {\n",
|
38 | 38 | " var script = document.createElement(\"script\");\n",
|
39 | 39 | " script.type = \"text/javascript\";\n",
|
40 |
| - " script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/[email protected].0/js-package/distr/lets-plot.min.js\";\n", |
| 40 | + " script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/[email protected].1/js-package/distr/lets-plot.min.js\";\n", |
41 | 41 | " script.onload = function() {\n",
|
42 | 42 | " window.letsPlotCall = function(f) {f();};\n",
|
43 | 43 | " window.letsPlotCallQueue.forEach(function(f) {f();});\n",
|
|
51 | 51 | " var div = document.createElement(\"div\");\n",
|
52 | 52 | " div.style.color = 'darkred';\n",
|
53 | 53 | " div.textContent = 'Error loading Lets-Plot JS';\n",
|
54 |
| - " document.getElementById(\"4DSxKL\").appendChild(div);\n", |
| 54 | + " document.getElementById(\"JnN9cv\").appendChild(div);\n", |
55 | 55 | " };\n",
|
56 |
| - " var e = document.getElementById(\"4DSxKL\");\n", |
| 56 | + " var e = document.getElementById(\"JnN9cv\");\n", |
57 | 57 | " e.appendChild(script);\n",
|
58 | 58 | " })();\n",
|
59 | 59 | " </script>"
|
|
77 | 77 | {
|
78 | 78 | "data": {
|
79 | 79 | "text/plain": [
|
80 |
| - "Lets-Plot Kotlin API v.hehe. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.6.0." |
| 80 | + "Lets-Plot Kotlin API v.4.6.1. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.6.1." |
81 | 81 | ]
|
82 | 82 | },
|
83 | 83 | "execution_count": 2,
|
|
106 | 106 | {
|
107 | 107 | "data": {
|
108 | 108 | "text/html": [
|
109 |
| - " <div id=\"mynfho\"></div>\n", |
| 109 | + " <div id=\"0l8qfx\"></div>\n", |
110 | 110 | " <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
|
111 | 111 | " \n",
|
112 | 112 | " (function() {\n",
|
|
131 | 131 | " };\n",
|
132 | 132 | " }\n",
|
133 | 133 | " \n",
|
134 |
| - " const containerDiv = document.getElementById(\"mynfho\");\n", |
| 134 | + " const containerDiv = document.getElementById(\"0l8qfx\");\n", |
135 | 135 | " let fig = null;\n",
|
136 | 136 | " \n",
|
137 | 137 | " function renderPlot() {\n",
|
|
221 | 221 | ],
|
222 | 222 | "source": [
|
223 | 223 | "letsPlot() + \n",
|
224 |
| - " geomPoint(x=0, y=0, size=10, color=\"#DA8459\") + \n", |
225 |
| - " geomText(x=0, y=0, label=\"text without nudge\") + \n", |
| 224 | + " geomPoint(x = 0, y = 0, size = 10, color = \"#DA8459\") + \n", |
| 225 | + " geomText(x = 0, y = 0, label = \"text without nudge\") + \n", |
226 | 226 | " ggsize(400, 300)"
|
227 | 227 | ]
|
228 | 228 | },
|
|
232 | 232 | "metadata": {},
|
233 | 233 | "source": [
|
234 | 234 | "#### 2. Unit Comparison: Pixel, Size, and Identity\n",
|
235 |
| - "The `'size'` unit enables precise positioning relative to point dimensions.\n", |
236 | 235 | "\n",
|
237 |
| - "In this example, the point has `size=30` and text is positioned at half that distance (`nudge_y=15`). When combined with `vjust/hjust`, this allows for placing text at specific locations relative to the point boundary." |
| 236 | + "The `\"size\"` unit enables precise positioning relative to point dimensions.\n", |
| 237 | + "\n", |
| 238 | + "In this example, the point has `size = 30` and text is positioned at half that distance (`nudgeY = 15`). When combined with `vjust`/`hjust`, this allows for placing text at specific locations relative to the point boundary." |
238 | 239 | ]
|
239 | 240 | },
|
240 | 241 | {
|
|
246 | 247 | {
|
247 | 248 | "data": {
|
248 | 249 | "text/html": [
|
249 |
| - " <div id=\"nuSyBd\"></div>\n", |
| 250 | + " <div id=\"PB9UUu\"></div>\n", |
250 | 251 | " <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
|
251 | 252 | " \n",
|
252 | 253 | " (function() {\n",
|
|
271 | 272 | " };\n",
|
272 | 273 | " }\n",
|
273 | 274 | " \n",
|
274 |
| - " const containerDiv = document.getElementById(\"nuSyBd\");\n", |
| 275 | + " const containerDiv = document.getElementById(\"PB9UUu\");\n", |
275 | 276 | " let fig = null;\n",
|
276 | 277 | " \n",
|
277 | 278 | " function renderPlot() {\n",
|
|
450 | 451 | }
|
451 | 452 | ],
|
452 | 453 | "source": [
|
453 |
| - "letsPlot() + \n", |
454 |
| - " xlim(-1 to 4) + \n", |
455 |
| - " geomPoint(x=0, y=1, size=5, color=\"#B9534C\") + \n", |
456 |
| - " geomText(x=0, y=1, label=\"identity 0.2\", nudgeY=0.2) + \n", |
457 |
| - " geomPoint(x=1, y=1, size=5, color=\"#DA8459\") + \n", |
458 |
| - " geomText(x=1, y=1, label=\"px 40\", nudgeY=40, nudgeUnit=\"px\") + \n", |
459 |
| - " geomPoint(x=2, y=1, size=30, color=\"#EEAB65\") + \n", |
460 |
| - " geomText(x=2, y=1, label=\"size 15\", nudgeY=15, nudgeUnit=\"size\") + \n", |
461 |
| - " geomPoint(x=3, y=1, size=30, color=\"#F6C971\") + \n", |
462 |
| - " geomText(x=3, y=1, label=\"size 15 vjust 0\", nudgeY=15, vjust=0, nudgeUnit=\"size\") + \n", |
463 |
| - " geomText(x=3, y=1, label=\"size -15 vjust 1\", nudgeY=-15, vjust=1, nudgeUnit=\"size\")" |
| 454 | + "letsPlot() +\n", |
| 455 | + " xlim(-1 to 4) +\n", |
| 456 | + " geomPoint(x = 0, y = 1, size = 5, color = \"#B9534C\") +\n", |
| 457 | + " geomText(x = 0, y = 1, label = \"identity 0.2\", nudgeY = 0.2) +\n", |
| 458 | + " geomPoint(x = 1, y = 1, size = 5, color = \"#DA8459\") +\n", |
| 459 | + " geomText(x = 1, y = 1, label = \"px 40\", nudgeY = 40, nudgeUnit = \"px\") +\n", |
| 460 | + " geomPoint(x = 2, y = 1, size = 30, color = \"#EEAB65\") +\n", |
| 461 | + " geomText(x = 2, y = 1, label = \"size 15\", nudgeY = 15, nudgeUnit = \"size\") +\n", |
| 462 | + " geomPoint(x = 3, y = 1, size = 30, color = \"#F6C971\") +\n", |
| 463 | + " geomText(x = 3, y = 1, label = \"size 15 vjust 0\", nudgeY = 15, vjust = 0, nudgeUnit = \"size\") +\n", |
| 464 | + " geomText(x = 3, y = 1, label = \"size -15 vjust 1\", nudgeY = -15, vjust = 1, nudgeUnit = \"size\")" |
464 | 465 | ]
|
465 | 466 | },
|
466 | 467 | {
|
467 | 468 | "cell_type": "markdown",
|
468 | 469 | "id": "b8f317a8-5aec-4ba7-8646-cbad83c13742",
|
469 | 470 | "metadata": {},
|
470 | 471 | "source": [
|
471 |
| - "#### 3. Parameter `unit` in `position_nudge()`" |
| 472 | + "#### 3. Parameter `unit` in `positionNudge()`" |
472 | 473 | ]
|
473 | 474 | },
|
474 | 475 | {
|
|
480 | 481 | {
|
481 | 482 | "data": {
|
482 | 483 | "text/html": [
|
483 |
| - " <div id=\"UXksSH\"></div>\n", |
| 484 | + " <div id=\"qBUfgi\"></div>\n", |
484 | 485 | " <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
|
485 | 486 | " \n",
|
486 | 487 | " (function() {\n",
|
|
505 | 506 | " };\n",
|
506 | 507 | " }\n",
|
507 | 508 | " \n",
|
508 |
| - " const containerDiv = document.getElementById(\"UXksSH\");\n", |
| 509 | + " const containerDiv = document.getElementById(\"qBUfgi\");\n", |
509 | 510 | " let fig = null;\n",
|
510 | 511 | " \n",
|
511 | 512 | " function renderPlot() {\n",
|
|
613 | 614 | ],
|
614 | 615 | "source": [
|
615 | 616 | "letsPlot() + \n",
|
616 |
| - " geomPoint(x=0, y=0, size=50, color=\"#DA8459\") + \n", |
617 |
| - " geomPoint(x=0, y=0, size=20, color=\"blue\", position=positionNudge(0, 25, \"size\")) + \n", |
618 |
| - " geomText(x=0, y=0, label=\"position_nudge size 25\", position=positionNudge(50, 25, \"size\"))" |
| 617 | + " geomPoint(x = 0, y = 0, size = 50, color = \"#DA8459\") + \n", |
| 618 | + " geomPoint(x = 0, y = 0, size = 20, color = \"blue\", position = positionNudge(0, 25, \"size\")) + \n", |
| 619 | + " geomText(x = 0, y = 0, label = \"position_nudge size 25\", position = positionNudge(50, 25, \"size\"))" |
619 | 620 | ]
|
620 | 621 | }
|
621 | 622 | ],
|
|
0 commit comments