lets_plot.theme

lets_plot.theme(*, line=None, rect=None, text=None, title=None, axis=None, axis_title=None, axis_title_x=None, axis_title_y=None, axis_text=None, axis_text_x=None, axis_text_y=None, axis_ticks=None, axis_ticks_x=None, axis_ticks_y=None, axis_ticks_length=None, axis_ticks_length_x=None, axis_ticks_length_y=None, axis_line=None, axis_line_x=None, axis_line_y=None, legend_text=None, legend_title=None, legend_position=None, legend_justification=None, legend_direction=None, panel_background=None, panel_grid=None, panel_grid_major=None, panel_grid_minor=None, panel_grid_major_x=None, panel_grid_minor_x=None, panel_grid_major_y=None, panel_grid_minor_y=None, plot_title=None, strip_background=None, strip_text=None, axis_tooltip=None, axis_tooltip_x=None, axis_tooltip_y=None)

Use theme() to modify individual components of a theme, allowing you to control all non-data components of the plot.

Parameters
linestr 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.

rectstr 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.

textstr 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.

titlestr 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.

axisstr 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, axis_title_x, axis_title_ystr 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. axis_title_* inherits from axis_title which inherits from text.

axis_text, axis_text_x, axis_text_ystr 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. axis_text_* inherits from axis_text which inherits from text.

axis_ticks, axis_ticks_x, axis_ticks_ystr 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. axis_ticks_* inherits from axis_ticks which inherits from line.

axis_ticks_length, axis_ticks_length_x, axis_ticks_length_yfloat

Length of tick marks.

axis_line, axis_line_x, axis_line_ystr 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. axis_line_* inherits from axis_line which inherits from line.

legend_textstr 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_titlestr 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, each value of float type between 0 and 1.

legend_justificationstr or list

Anchor point for positioning legend. If parameter is a list, then it should be a two-element numeric vector. The pair [0, 0] corresponds to the bottom left corner, the pair [1, 1] corresponds to the top right. For string parameter the only possible value is ‘center’.

legend_direction{‘horizontal’, ‘vertical’}

Layout of items in legends.

panel_backgroundstr 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, panel_grid_major, panel_grid_minor, panel_grid_major_x, panel_grid_major_y, panel_grid_minor_x, panel_grid_minor_ystr or dict

Grid lines. Specify major grid lines or minor grid lines separately if needed. Set ‘blank’ or result of element_blank() to draw nothing. Set element_line() to specify grid line parameters. panel_grid_*_* inherits from panel_grid_* which inherits from panel_grid, which in turn inherits from line.

plot_titlestr 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_backgroundstr 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_textstr 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, axis_tooltip_x, axis_tooltip_ystr 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. axis_tooltip_* inherits from axis_tooltip which inherits from rect.

Returns
FeatureSpec

Theme specification.

Examples

 1import numpy as np
 2from lets_plot import *
 3LetsPlot.setup_html()
 4n = 100
 5np.random.seed(42)
 6x = np.random.normal(size=n)
 7c = np.random.choice(['a', 'b', 'c'], size=n)
 8ggplot({'x': x, 'class': c}, aes('x')) + \
 9    geom_density(aes(color='class'), size=2) + \
10    ggtitle('Density of classes') + \
11    theme(axis_line=element_line(size=4), \
12          axis_ticks_length=10, \
13          axis_title_y='blank', \
14          legend_position=[1, 1], legend_justification=[1, 1], \
15          panel_background=element_rect(color='black', fill='#eeeeee', size=2), \
16          panel_grid=element_line(color='black', size=1))