| |
- builtins.Exception(builtins.BaseException)
-
- LingMapError
- builtins.object
-
- LingMap
class LingMap(builtins.object) |
|
LingMap(languages=[])
Lingtypology map object
Parameter languages: list of strings, default []
Attributes:
-----------
Features
---
colors: list of html codes for colors
Colors that represent features.
You can either use the default colors or set yours.
stroke_colors: list of html codes for colors
Colors that represent additional (stroke) features.
You can either use the default colors or set yours.
shapes: list of characters
If you use shapes instead of colors, you can either use the default shapes or set yours.
Shapes are Unicode symbols.
---
Map
---
start_location: (float, float), default (0, 0)
Coordinates of the map (latitude, longitude).
start_zoom: int, default 3
Imitial zoom level.
control_scale: bool, default True
Whether to add control scale.
prefer_canvas: bool, default False
Use canvas instead of SVG.
If set to True, the map may be more responsive in case you have a lot of markers.
title: str, default None
You can add a title to the map.
---
Legend
---
legend: bool, default True
Whether to add legend
stroke_legend: bool True
Whether to add stroke legend
legend_title: str, default Legend
Legend title
stroke_legend_title: str, default Legend
Stroke legend title
legend_position: str, default 'bottomright'
Legend position.
Available values: 'right', 'left', 'top', 'bottom', 'bottomright', 'bottomleft', 'topright', 'topleft'
stroke_legend_position: str, default 'bottomleft'
Stroke legend position.
Available values: 'right', 'left', 'top', 'bottom', 'bottomright', 'bottomleft', 'topright', 'topleft'
---
Markers
---
use_shapes: bool, default False
Whether to use shapes instead of colors.
radius: int, default 7
Circle marker radius.
stroke_radius: int, default 12
Radius of markers if you use stroke features.
stroked: bool, default True
Whether to add stroke to markers.
unstroked: bool, default True
If set to True, circle marker will merge if you zoom out without stroke between them.
It multiplies the number of markers by 2. For better performance set it to False.
To understand how it looks see the example below.
unstroked = True (default):
┌——————————┐
│ ▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒▒▒▒ └—————┐
│ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
└—————┐ ▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒▒▒▒ │
└——————————┘
unstroked = False:
┌——————————┐
│ ▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒┌———┴——————┐
│ ▒▒▒▒▒│ ▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒│ ▒▒▒▒▒▒▒▒ │
└——————┤ ▒▒▒▒▒▒▒▒ │
│ ▒▒▒▒▒▒▒▒ │
└——————————┘
---
Popups
---
languages_in_popups: bool, default True
Whether to show links to Glottolog website in popups
html_popups: bool, default False
Setting it to True allows to put full html pages into popups (using folium.IFrame).
---
Control
---
control: bool, default False
Whether to add LayerControls and group by features.
stroke_control: bool, default False
Whether to add LayerControls and group by stroke features.
control_position: str, default 'topright'
Position of LayerControls.
May be ‘topleft’, ‘topright’, ‘bottomleft’ or ‘bottomright’.
---
Other
---
heatmap_only: bool, default False
If set to true no markers will be rendered.
colormap_colors: tuple, default ('#ffffff','#4a008f')
Default colors for the colormap.
--- |
|
Methods defined here:
- __init__(self, languages=[])
- __init__
Sets self.languages turning it into a tuple.
If no languages are given, sets self.heatmap_only to true.
Then it sets everything else.
- add_custom_coordinates(self, custom_coordinates)
- Set custom coordinates
By default coordinates for the languages are taken from the Glottolog database.
If you have coordinates and want to use them, use this function.
custom_coordinates: list of custom_coordinates (tuples)
Length of the list should equal to length of languages.
- add_features(self, features, radius=7, numeric=False, control=False, use_shapes=False)
- Add features
features: list of strings
List of features. Length of the list should equal to length of languages.
By default, if you add features, a legend will appear. To shut it down set
"legend" attribute to False.
To change the title of the legend use "legend_title" attribute.
radius: int, default 7
Marker radius.
numeric: bool, default False
Whether to assign different color to each feature (False),
or to assign a color from colormap (True).
You can set it to True only in case your features are numeric,
for example "Number of phonemes", and stroke features are not given.
control: bool, default False
Whether to add LayerControls to the map.
It allows interactive turning on/off given features.
use_shapes: bool, default False
Whether to use shapes instead of colors. This option allows to represent features as shapes.
Shapes are Unicode charaters like ⬤ or ◼. You can replace or add to default symbols by
changing attribute "shapes".
If colors are not a viable option for you, you can set this option to True.
- add_heatmap(self, heatmap=[])
- Add heatmap
heatmap: list of tuples
Coordinates for the heatmap.
- add_line(self, locations, tooltip='', popup='', color='black', smooth_factor=1.0)
- Add one line
To add several lines, use this function several times.
locations: list of two tuples
Coordinates of two points to draw a line.
tooltip: str, default ''
popups: str, default ''
color: str, default 'black'
smooth_factor: float, default 1.0
- add_minichart(self, data)
- Not implemented
- add_minimap(self, position='bottomleft', width=150, height=150, collapsed_width=25, collapsed_height=25, zoom_animation=True)
- Add minimap
position: str, default 'bottomleft'
width: int, default 150
height: int, default 150
collapsed_width: int, default 25
collapsed_height: int, default 25
zoom_animation: bool, default True
You can disable zoom animation for better performance.
- add_popups(self, popups, parse_html=False)
- Add popups to markers
popups: list of strings
List of popups. Length of the list should equal to length of languages.
parse_html: bool, default False
By default (False) you can add small pieces of html code.
If you need to add full html pages to popups, you need to set the option to True.
- add_rectangle(self, locations, tooltip='', popup='', color='black')
- Add one rectangle
To add several rectangles, use this function several times.
locations: list of two tuples
Coordinates of two points to draw a rectangle.
tooltip: str, default ''
popups: str, default ''
color: str, default 'black'
- add_stroke_features(self, features, radius=12, numeric=False, control=False)
- Add stroke features
This function assigns features to strokes of markers.
features: list of strings
List of features. Length of the list should equal to length of languages.
By default, if you add features, a legend will appear. To shut it down set
"stroke_legend" attribute to False.
To change the title of the legend use "stroke_legend_title" attribute.
radius: int, default 12
Marker radius.
control: bool, default False
Whether to add LayerControls to the map.
It allows interactive turning on/off given features.
- add_tooltips(self, tooltips)
- Add tooltips to markers
tooltips: list of strings
List of tooltips. Length of the list should equal to length of languages.
- render(self)
- Renders the map returns it as HTML string
- save(self, path)
- Save to file
path: str
Path to the output HTML file.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class LingMapError(builtins.Exception) |
|
LingMapError(value)
All special exceptions |
|
- Method resolution order:
- LingMapError
- builtins.Exception
- builtins.BaseException
- builtins.object
Methods defined here:
- __init__(self, value)
- Initialize self. See help(type(self)) for accurate signature.
- __str__(self)
- Return str(self).
Data descriptors defined here:
- __weakref__
- list of weak references to the object (if defined)
Static methods inherited from builtins.Exception:
- __new__(*args, **kwargs) from builtins.type
- Create and return a new object. See help(type) for accurate signature.
Methods inherited from builtins.BaseException:
- __delattr__(self, name, /)
- Implement delattr(self, name).
- __getattribute__(self, name, /)
- Return getattr(self, name).
- __reduce__(...)
- Helper for pickle.
- __repr__(self, /)
- Return repr(self).
- __setattr__(self, name, value, /)
- Implement setattr(self, name, value).
- __setstate__(...)
- with_traceback(...)
- Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.
Data descriptors inherited from builtins.BaseException:
- __cause__
- exception cause
- __context__
- exception context
- __dict__
- __suppress_context__
- __traceback__
- args
| |