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

Updates in docstrings #466

Merged
merged 80 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b66c269
Update docstring for geom_point() function.
ASmirnov-HORIS Feb 16, 2021
b760969
Docstring: Update data, map and map_join parameters description.
ASmirnov-HORIS Feb 25, 2021
639b438
Updated core.py docstrings.
EArkhipova-HORIS Feb 26, 2021
7a6ba28
Minor fixes
EArkhipova-HORIS Mar 2, 2021
3003b51
Update examples in coord.py docstrings, update geom_extras.py docstrings
EArkhipova-HORIS Mar 3, 2021
f27c925
Docstrings: replace >>> to :linenos: in geom.py.
ASmirnov-HORIS Mar 12, 2021
19f7c85
Update examples in plot.py, update docstring in label.py.
EArkhipova-HORIS Mar 15, 2021
d33102b
Update docstring for the geocode() function.
ASmirnov-HORIS Mar 17, 2021
33afa10
Update docstrings in geo_data.
ASmirnov-HORIS Mar 19, 2021
b33d331
Add link to documentation page for formatting in tooltips and geom_te…
ASmirnov-HORIS Mar 24, 2021
ab0cb8c
Fix lists in docstrings notes (according to Numpydoc and rst rules).
ASmirnov-HORIS Mar 24, 2021
c8c1ced
Update links in docstrings.
ASmirnov-HORIS Mar 24, 2021
f019ead
Fix errors of the rebase conflicts resolving.
ASmirnov-HORIS Aug 20, 2021
e5b5038
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Aug 26, 2021
48361d9
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Aug 27, 2021
8013613
Move the notebook 'map_US_household_income' to the lets-plot-docs rep…
ASmirnov-HORIS Aug 30, 2021
0cb2498
Update docstrings for the stat_corr() function.
ASmirnov-HORIS Aug 30, 2021
26951f2
Update docstrings for geo_data and tilesets.
ASmirnov-HORIS Aug 31, 2021
b6ede67
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Sep 2, 2021
1744657
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Sep 2, 2021
1e7f7d5
Update examples in some docstrings (geometries).
ASmirnov-HORIS Sep 2, 2021
b1ff9c7
Tiny fix in the docstrings.
ASmirnov-HORIS Sep 10, 2021
b516830
Update links to the documentation site and remove the README_PYTHON.m…
ASmirnov-HORIS Sep 10, 2021
9c99338
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Sep 13, 2021
53d48da
Fix conflicts after merging with master.
ASmirnov-HORIS Sep 13, 2021
d44b269
Fix docstrings.
ASmirnov-HORIS Sep 13, 2021
837bf1c
Move example notebooks to the lets-plot-docs repository.
ASmirnov-HORIS Sep 20, 2021
73e520d
Tiny fix in docstrings for scales.
ASmirnov-HORIS Sep 21, 2021
cb78333
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Sep 21, 2021
3699a55
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Sep 21, 2021
a998004
Remove some markdown, images and notebooks from the docs/ directory. …
ASmirnov-HORIS Sep 23, 2021
839fac0
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Sep 24, 2021
9416a7f
Fix conflicts after merging with upstream/master.
ASmirnov-HORIS Sep 24, 2021
6f5efba
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Sep 27, 2021
83eda98
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Sep 27, 2021
f0178b3
Remove extra datasets from the docs/ directory.
ASmirnov-HORIS Sep 27, 2021
6af62fb
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Sep 29, 2021
4a67acf
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Sep 29, 2021
153dfc6
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 12, 2021
258d666
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 12, 2021
14bb83e
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 13, 2021
600f485
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 15, 2021
bac7d14
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 18, 2021
5fa1b0b
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 19, 2021
228a0a4
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 19, 2021
91d9c8d
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 20, 2021
c557703
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 20, 2021
c25215b
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 20, 2021
60b9d43
Update docstring for geom_point() function.
ASmirnov-HORIS Feb 16, 2021
7d56a67
Docstring: Update data, map and map_join parameters description.
ASmirnov-HORIS Feb 25, 2021
0b81f55
Minor fixes
EArkhipova-HORIS Mar 2, 2021
43b1e8f
Update examples in coord.py docstrings, update geom_extras.py docstrings
EArkhipova-HORIS Mar 3, 2021
4beaf1e
Update examples in plot.py, update docstring in label.py.
EArkhipova-HORIS Mar 15, 2021
0b54bd5
Add link to documentation page for formatting in tooltips and geom_te…
ASmirnov-HORIS Mar 24, 2021
48e15f6
Fix lists in docstrings notes (according to Numpydoc and rst rules).
ASmirnov-HORIS Mar 24, 2021
e99686a
Update links in docstrings.
ASmirnov-HORIS Mar 24, 2021
c4a0b86
Fix errors of the rebase conflicts resolving.
ASmirnov-HORIS Aug 20, 2021
e7f8980
Merge branch 'master' of github.com:ASmirnov-HORIS/lets-plot
ASmirnov-HORIS Oct 20, 2021
41d6282
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 21, 2021
6c1a361
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 21, 2021
39e423a
Update the docs/ structure.
ASmirnov-HORIS Oct 21, 2021
a26c62b
Update the 'themes' notebook.
ASmirnov-HORIS Oct 21, 2021
33aad73
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 25, 2021
6331253
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 25, 2021
4010732
Add docstrings to the new themes.
ASmirnov-HORIS Oct 26, 2021
2c759f4
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 26, 2021
40bb961
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 26, 2021
ae1b563
Update docstring for the stat_corr() function.
ASmirnov-HORIS Oct 26, 2021
5cd658e
Update the 'themes' notebook.
ASmirnov-HORIS Oct 26, 2021
89b6a96
Update docstrings for the theme() function.
ASmirnov-HORIS Oct 28, 2021
d29429c
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 28, 2021
ac7254e
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 28, 2021
14292ee
Remove examples with corr stat.
ASmirnov-HORIS Oct 28, 2021
eb82ae4
Update the 'Notes' section in docstrings.
ASmirnov-HORIS Oct 28, 2021
08ba199
Update parameter types in docstrings.
ASmirnov-HORIS Oct 29, 2021
8a86873
Remove extra folder from the docs/ directory.
ASmirnov-HORIS Oct 29, 2021
77f8884
Merge branch 'master' of github.com:JetBrains/lets-plot
ASmirnov-HORIS Oct 29, 2021
a5f36c3
Merge branch 'master' into sphinx-doc
ASmirnov-HORIS Oct 29, 2021
7e04b0c
Remove extra notebook from the docs/dev/ directory.
ASmirnov-HORIS Oct 29, 2021
1f32bb2
Remove datetime_formatting from the docs/dev/ directory (moved to docs).
ASmirnov-HORIS Oct 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add docstrings to the new themes.
  • Loading branch information
ASmirnov-HORIS committed Oct 26, 2021
commit 401073262d6ea8b0fed3f4be95ba0809dd75cee5
318 changes: 267 additions & 51 deletions python-package/lets_plot/plot/theme_.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,92 @@ def theme(*,
):
"""
Use `theme()` to modify individual components of a theme,
allowing you to control the appearance of all non-data components of the plot.
allowing you to control all non-data components of the plot.

Parameters
----------
axis_title : str or `FeatureSpec`
Label of axes. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_title_x : str or `FeatureSpec`
x axis label. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_title_y : str or `FeatureSpec`
y axis label. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_text : str or `FeatureSpec`
Tick labels along axes. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_text_x : str or `FeatureSpec`
x axis tick labels. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_text_y : str or `FeatureSpec`
y axis tick labels. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_ticks : str or `FeatureSpec`
Tick marks along axes. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_ticks_x : str or `FeatureSpec`
x axis tick marks. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_ticks_y : str or `FeatureSpec`
y axis tick marks. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_line : str or `FeatureSpec`
Lines along axes. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_line_x : str or `FeatureSpec`
Line along x axis. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_line_y : str or `FeatureSpec`
Line along y axis. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
line : str or dict
All line elements.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify line parameters.
rect : str or dict
All rectangular elements.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_rect()` to specify rectangular element parameters.
text : str or dict
All text elements.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify text parameters.
title : str or dict
All title elements: plot, axes, legends.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify title text parameters, inherited from `text`.
axis : str or dict
All axis elements: lines, ticks, texts, titles.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify axes parameters.
axis_title : str or dict
Labels of axes.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify axes label parameters, inherited from `text`.
axis_title_x : str or dict
x axis label.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify x axis label parameters, inherited from `axis_title`.
axis_title_y : str or dict
y axis label.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify y axis label parameters, inherited from `axis_title`.
axis_text : str or dict
Tick labels along axes.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify all axes tick label parameters, inherited from `text`.
axis_text_x : str or dict
x axis tick labels.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify all x axis tick label parameters, inherited from `axis_text`.
axis_text_y : str or dict
y axis tick labels.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify all y axis tick label parameters, inherited from `axis_text`.
axis_ticks : str or dict
Tick marks along axes.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify all tick mark parameters, inherited from `line`.
axis_ticks_x : str or dict
x axis tick marks.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify all x axis tick mark parameters, inherited from `axis_ticks`.
axis_ticks_y : str or dict
y axis tick marks.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify all y axis tick mark parameters, inherited from `axis_ticks`.
axis_ticks_length : int
Length of tick marks.
axis_ticks_length_x : int
Length of x axis tick marks.
axis_ticks_length_y : int
Length of y axis tick marks.
axis_line : str or dict
Lines along axes.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify line parameters along all axes, inherited from `line`.
axis_line_x : str or dict
Line along x axis.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify line parameters along x axis, inherited from `axis_line`.
axis_line_y : str or dict
Line along y axis.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_line()` to specify line parameters along y axis, inherited from `axis_line`.
legend_text : str or dict
Legend item labels.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify legend item label parameters, inherited from `text`.
legend_title : str or dict
Title of legend.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify legend title parameters, inherited from `title`.
legend_position : {'none', 'left', 'right', 'bottom', 'top'} or list
The position of legends. To remove the plot legend, use the 'none' value.
If parameter is a list, then it should be a two-element numeric vector,
Expand All @@ -101,12 +159,62 @@ def theme(*,
For string parameter the only possible value is 'center'.
legend_direction : {'horizontal', 'vertical'}
Layout of items in legends.
axis_tooltip : str or `FeatureSpec`
Axes tooltips. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_tooltip_x : str or `FeatureSpec`
x axis tooltips. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
axis_tooltip_y : str or `FeatureSpec`
y axis tooltips. Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
panel_background : str or dict
Background of plotting area.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_rect()` to specify plotting area background parameters, inherited from `rect`.
panel_grid : str or dict
Grid lines.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify grid line parameters, inherited from `line`.
panel_grid_major : str or dict
Major grid lines.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify major grid line parameters, inherited from `panel_grid`.
panel_grid_minor : str or dict
Minor grid lines.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify minor grid line parameters, inherited from `panel_grid`.
panel_grid_major_x : str or dict
Major grid lines along x axis.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify major grid line parameters along x axis, inherited from `panel_grid_major`.
panel_grid_minor_x : str or dict
Minor grid lines along x axis.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify minor grid line parameters along x axis, inherited from `panel_grid_minor`.
panel_grid_major_y : str or dict
Major grid lines along y axis.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify major grid line parameters along y axis, inherited from `panel_grid_major`.
panel_grid_minor_y : str or dict
Minor grid lines along y axis.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_line()` to specify minor grid line parameters along y axis, inherited from `panel_grid_minor`.
plot_title : str or dict
Plot title.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify plot title parameters, inherited from `title`.
strip_background : str or dict
Background of facet labels.
Set 'blank' or result of `element_blank()` to draw nothing.
Set `element_rect()` to specify facet label background parameters, inherited from `rect`.
strip_text : str or dict
Facet labels.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_text()` to specify facet label parameters, inherited from `text`.
axis_tooltip : str or dict
Axes tooltips.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_rect()` to specify axes tooltip parameters, inherited from `rect`.
axis_tooltip_x : str or dict
x axis tooltips.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_rect()` to specify x axis tooltip parameters, inherited from `axis_tooltip`.
axis_tooltip_y : str or dict
y axis tooltips.
Set 'blank' or result of `element_blank()` to draw nothing and assign no space.
Set `element_rect()` to specify y axis tooltip parameters, inherited from `axis_tooltip`.

Returns
-------
Expand All @@ -117,41 +225,50 @@ def theme(*,
--------
.. jupyter-execute::
:linenos:
:emphasize-lines: 11-13
:emphasize-lines: 11-16

import numpy as np
from lets_plot import *
LetsPlot.setup_html()
cats = ['a', 'b', 'c', 'd', 'e']
n = 100
np.random.seed(42)
p = np.random.uniform(size=len(cats))
x = np.random.choice(cats, p=p/p.sum(), size=1000)
ggplot({'x': x}, aes(x='x')) + \\
geom_bar(aes(fill='x')) + \\
scale_fill_discrete(name='cat') + \\
theme(axis_title_x='blank', axis_text_x='blank', \\
axis_ticks_x='blank', axis_line='blank', \\
legend_position='bottom')
x = np.random.normal(size=n)
c = np.random.choice(['a', 'b', 'c'], size=n)
ggplot({'x': x, 'class': c}, aes('x')) + \\
geom_density(aes(color='class'), size=2) + \\
ggtitle('Density of classes') + \\
theme(axis_line=element_line(size=4), \\
axis_ticks_length=10, \\
axis_title_y='blank', \\
legend_position=[1, 1], legend_justification=[1, 1], \\
panel_background=element_rect(color='black', fill='#eeeeee', size=2), \\
panel_grid=element_line(color='black', size=1))

|

.. jupyter-execute::
:linenos:
:emphasize-lines: 12-13
:emphasize-lines: 14-19

import numpy as np
from lets_plot import *
LetsPlot.setup_html()
n = 100
n = 1000
np.random.seed(42)
x = np.random.normal(size=n)
y = np.random.normal(size=n)
v = np.random.uniform(size=n)
ggplot({'x': x, 'y': y, 'v': v}, aes('x', 'y')) + \\
geom_point(aes(color='v')) + \\
scale_color_gradient(name='value') + \\
theme(axis_tooltip=element_blank(), legend_direction='horizontal', \\
legend_position=[1, 1], legend_justification=[1, 1])
p = np.random.uniform(size=7)
x = np.random.choice(range(p.size), p=p/p.sum(), size=n)
c = np.random.choice(['a', 'b', 'c'], p=[.5, .3, .2], size=n)
ggplot({'x': x, 'class': c}) + \\
geom_bar(aes('x', fill='x')) + \\
scale_y_continuous(breaks=list(range(0, 151, 25))) + \\
scale_fill_discrete() + \\
facet_grid(y='class') + \\
theme(axis_line_x='blank', \\
axis_ticks=element_line(color='white'), \\
panel_grid_major_x='blank', \
strip_background=element_rect(color='black', fill='white'), \\
axis_tooltip=element_rect(color='black', fill='white'), \\
legend_position='top')

"""

Expand Down Expand Up @@ -204,6 +321,41 @@ def element_rect(
# ToDo: linetype
blank=False,
) -> dict:
"""
Specifies how non-data components of the plot are drawn.
This theme element draws borders and backgrounds.

Parameters
----------
fill : str
Fill color.
color : str
Border color.
size : int
Border size.
blank : bool, default=False
If True - draws nothing, and assigns no space.

Returns
-------
`dict`
Theme element specification.

Examples
--------
.. jupyter-execute::
:linenos:
:emphasize-lines: 7

import numpy as np
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(42)
data = {'x': np.random.normal(size=1000)}
ggplot(data, aes(x='x')) + geom_histogram() + \\
theme(panel_background=element_rect())

"""
return locals()


Expand All @@ -213,6 +365,39 @@ def element_line(
# ToDo: linetype, lineend, arrow
blank=False,
) -> dict:
"""
Specifies how non-data components of the plot are drawn.
This theme element draws lines.

Parameters
----------
color : str
Line color.
size : int
Line size.
blank : bool, default=False
If True - draws nothing, and assigns no space.

Returns
-------
`dict`
Theme element specification.

Examples
--------
.. jupyter-execute::
:linenos:
:emphasize-lines: 7

import numpy as np
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(42)
data = {'x': np.random.normal(size=1000)}
ggplot(data, aes(x='x')) + geom_histogram() + \\
theme(panel_grid=element_line(size=3))

"""
return locals()


Expand All @@ -223,4 +408,35 @@ def element_text(
# ToDo: hjust, vjust, angle, lineheight, margin
blank=False,
) -> dict:
"""
Specifies how non-data components of the plot are drawn.
This theme element draws texts.

Parameters
----------
color : str
Text color.
blank : bool, default=False
If True - draws nothing, and assigns no space.

Returns
-------
`dict`
Theme element specification.

Examples
--------
.. jupyter-execute::
:linenos:
:emphasize-lines: 7

import numpy as np
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(42)
data = {'x': np.random.normal(size=1000)}
ggplot(data, aes(x='x')) + geom_histogram() + \\
theme(axis_text=element_text(color='#bdbdbd'))

"""
return locals()
Loading