Skip to content
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

Fixes in docstrings #1063

Merged
merged 8 commits into from
Mar 26, 2024
Prev Previous commit
Next Next commit
Add examples with hjust/vjust to the docstrings of the functions geom…
…_text()/geom_label().
  • Loading branch information
ASmirnov-HORIS committed Mar 25, 2024
commit 5b156862fb8e7942a66497d178932920ba4b8777
50 changes: 50 additions & 0 deletions python-package/lets_plot/plot/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6169,6 +6169,31 @@ def geom_text(mapping=None, *, data=None, stat=None, position=None, show_legend=

|

.. jupyter-execute::
:linenos:
:emphasize-lines: 16

import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.DataFrame({
"x": [0, -1, -1, -1, 0, 0, 1, 1, 1],
"y": [0, -1, 1, 0, -1, 1, -1, 0, 1],
"hjust": [.5, 1, 1, 1, .5, .5, 0, 0, 0],
"vjust": [.5, 1, 0, .5, 1, 0, 1, .5, 0],
}).assign(
label=lambda r: ("hjust=" + r["hjust"].astype(str)).str.cat(
"vjust=" + r["vjust"].astype(str),
sep='\n'
)
)
ggplot(df, aes("x", "y")) + \\
geom_text(aes(label="label", hjust="hjust", vjust="vjust")) + \\
geom_point() + \\
xlim(-1.2, 1.2) + ylim(-1.2, 1.2)

|

.. jupyter-execute::
:linenos:
:emphasize-lines: 10-11
Expand Down Expand Up @@ -6372,6 +6397,31 @@ def geom_label(mapping=None, *, data=None, stat=None, position=None, show_legend

|

.. jupyter-execute::
:linenos:
:emphasize-lines: 16

import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.DataFrame({
"x": [0, -1, -1, -1, 0, 0, 1, 1, 1],
"y": [0, -1, 1, 0, -1, 1, -1, 0, 1],
"hjust": [.5, 1, 1, 1, .5, .5, 0, 0, 0],
"vjust": [.5, 1, 0, .5, 1, 0, 1, .5, 0],
}).assign(
label=lambda r: ("hjust=" + r["hjust"].astype(str)).str.cat(
"vjust=" + r["vjust"].astype(str),
sep='\n'
)
)
ggplot(df, aes("x", "y")) + \\
geom_label(aes(label="label", hjust="hjust", vjust="vjust")) + \\
geom_point() + \\
xlim(-1.2, 1.2) + ylim(-1.2, 1.2)

|

.. jupyter-execute::
:linenos:
:emphasize-lines: 10-11
Expand Down