Skip to content

Commit

Permalink
Merge pull request #1462 from CartoDB/feature/1419-review-doc-rc1
Browse files Browse the repository at this point in the history
Review doc rc1
  • Loading branch information
elenatorro committed Jan 10, 2020
2 parents 9ed10e6 + 3d04c71 commit fcbee1c
Show file tree
Hide file tree
Showing 59 changed files with 582 additions and 84,130 deletions.
10 changes: 4 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,20 @@ Interactive vector maps can be created programmatically in CARTOframes. In addit

.. code:: python
from cartoframes.viz import Map
from cartoframes.viz.helpers import color_continuous_layer
from cartoframes.viz import Layer, color_continuous_style
from cartoframes.auth import set_default_credentials
set_default_credentials('cartoframes')
# display map in a notebook
Map(color_continuous_layer('brooklyn_poverty', 'poverty_per_pop'))
Layer('brooklyn_poverty', color_continuous_style('poverty_per_pop'))
Publish map to CARTO
^^^^^^^^^^^^^^^^^^^^

.. code:: python
from cartoframes.viz import Map
from cartoframes.viz.helpers import color_continuous_layer
from cartoframes.viz import Map, Layer, color_continuous_style
from cartoframes.auth import set_default_credentials
set_default_credentials(
Expand All @@ -138,7 +136,7 @@ Publish map to CARTO
)
# display map in a notebook
bk_map = Map(color_continuous_layer('brooklyn_poverty', 'poverty_per_pop'))
bk_map = Map(Layer('brooklyn_poverty', color_continuous_style('poverty_per_pop')))
bk_map.publish('Brooklyn Poverty')
This will publish a map like `this one <https://cartoframes.carto.com/kuviz/2a7badc3-00b3-49d0-9bc8-3b138542cdcf>`__.
Expand Down
11 changes: 7 additions & 4 deletions cartoframes/viz/styles/animation_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
from ..popups import popup_element


def animation_style(value, duration=20, color=None, size=None, opacity=None,
stroke_color=None, stroke_width=None):
def animation_style(value, duration=20, fade_in=1, fade_out=1, color=None,
size=None, opacity=None, stroke_color=None, stroke_width=None):
"""Helper function for quickly creating an animated style.
Args:
value (str): Column to symbolize by.
color (str, optional): Hex, rgb or named color value. Default is '#EE5D5A' for point geometries,
duration (float, optional): Time of the animation in seconds. Default is 20s.
fade_in (float, optional): Time of fade in transitions in seconds. Default is 1s.
fade_out (float, optional): Time of fade out transitions in seconds. Default is 1s.
color (str, optional): Hex, rgb or named color value. Default is '#EE5D5A' for points,
'#4CC8A3' for lines and #826DBA for polygons.
size (int, optional): Size of point or line features.
opacity (float, optional): Opacity value. Default is 1 for points and lines and
Expand All @@ -23,7 +26,7 @@ def animation_style(value, duration=20, color=None, size=None, opacity=None,
cartoframes.viz.style.Style
"""
fade = '(1, 1)'
fade = '({0}, {1})'.format(fade_in, fade_out)
data = {
'point': {
'color': 'opacity({0}, {1})'.format(
Expand Down
145 changes: 45 additions & 100 deletions docs/developer-center/examples/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
"desc": "Change CARTO Table Privacy",
"file": "change_carto_table_privacy",
"path": "data_workflows"
}, {
"title": "Animate a DataFrame by date",
"desc": "Animate a DataFrame by date",
"file": "date_columns_in_dataframes",
"path": "data_workflows"
}]
}, {
"title": "Data Enrichment",
Expand Down Expand Up @@ -80,36 +75,6 @@
"desc": "Add a Layer",
"file": "add_layer",
"path": "layers"
}, {
"title": "Add Basic Widget",
"desc": "Add a basic Widget",
"file": "add_basic_widget_layer",
"path": "layers"
}, {
"title": "Add Basic Legend",
"desc": "Add a basic Legend",
"file": "add_basic_legend_layer",
"path": "layers"
}, {
"title": "Add Popup on Click",
"desc": "Add popup on click to layer",
"file": "add_popup_click_layer",
"path": "layers"
}, {
"title": "Add Popup on Hover",
"desc": "Add popup on hover to layer",
"file": "add_popup_hover_layer",
"path": "layers"
}, {
"title": "Add Basic Style",
"desc": "Add basic style to a layer",
"file": "add_style_layer",
"path": "layers"
}, {
"title": "Add Data Driven Style",
"desc": "Add a data driven style to a layer",
"file": "add_data_driven_style_layer",
"path": "layers"
}, {
"title": "Add Multiple Layers",
"desc": "Add multiple Layers",
Expand Down Expand Up @@ -140,57 +105,52 @@
"path": "map_configuration"
}]
}, {
"title": "Visualization Layer Helpers",
"title": "Visualization Helpers",
"samples": [{
"title": "Color Category Layer",
"desc": "Color Category Layer",
"file": "color_category_layer",
"path": "visualization_layers"
}, {
"title": "Color Continuous Layer",
"desc": "Color Continuous Layer",
"file": "color_continuous_layer",
"path": "visualization_layers"
}, {
"title": "Color Bins Layer",
"desc": "Color Bins Layer",
"file": "color_bins_layer",
"path": "visualization_layers"
}, {
"title": "Size Category Layer",
"desc": "Size Category Layer",
"file": "size_category_layer",
"path": "visualization_layers"
}, {
"title": "Size Continuous Layer",
"desc": "Size Continuous Layer",
"file": "size_continuous_layer",
"path": "visualization_layers"
}, {
"title": "Size Bins Layer",
"desc": "Size Bins Layer",
"file": "size_bins_layer",
"path": "visualization_layers"
}, {
"title": "Cluster Size Layer",
"desc": "Cluster Size Layer",
"file": "cluster_size_layer",
"path": "visualization_layers"
}, {
"title": "Animation Layer",
"desc": "Animation Layer",
"file": "animation_layer",
"path": "visualization_layers"
}, {
"title": "Isolines Layer",
"desc": "Isolines Layer",
"file": "isolines_layer",
"path": "visualization_layers"
}, {
"title": "Combine Visualization Layers",
"desc": "Combine visualization layers",
"file": "combine_visualization_layers",
"path": "visualization_layers"
"title": "Color Category Style",
"desc": "Color Category Style",
"file": "color_category_style",
"path": "styles"
}, {
"title": "Color Continuous Style",
"desc": "Color Continuous Style",
"file": "color_continuous_style",
"path": "styles"
}, {
"title": "Color Bins Style",
"desc": "Color Bins Style",
"file": "color_bins_style",
"path": "styles"
}, {
"title": "Size Category Style",
"desc": "Size Category Style",
"file": "size_category_style",
"path": "styles"
}, {
"title": "Size Continuous Style",
"desc": "Size Continuous Style",
"file": "size_continuous_style",
"path": "styles"
}, {
"title": "Size Bins Style",
"desc": "Size Bins Style",
"file": "size_bins_style",
"path": "styles"
}, {
"title": "Cluster Size Style",
"desc": "Cluster Size Style",
"file": "cluster_size_style",
"path": "styles"
}, {
"title": "Animation Style",
"desc": "Animation Style",
"file": "animation_style",
"path": "styles"
}, {
"title": "Combine Visualization Styles",
"desc": "Combine visualization styles",
"file": "combine_visualization_styles",
"path": "styles"
}]
}, {
"title": "Legends",
Expand Down Expand Up @@ -239,11 +199,6 @@
"desc": "Legend Line Geometry",
"file": "legend_line_geometry",
"path": "legends"
}, {
"title": "Use Stroke Color in Legend",
"desc": "Use stroke color in legend",
"file": "stroke_color_legend",
"path": "legends"
}, {
"title": "Use Opacity in Legend",
"desc": "Use opacity in legend",
Expand Down Expand Up @@ -282,11 +237,6 @@
"desc": "Time Series Widget",
"file": "time_series_widget",
"path": "widgets"
}, {
"title": "Animation Widget to Style Property",
"desc": "Animation Widget to Style Property",
"file": "animation_widget_style_property",
"path": "widgets"
}, {
"title": "Multiple Widgets",
"desc": "Multiple Widgets",
Expand Down Expand Up @@ -315,11 +265,6 @@
"desc": "Multiple Popup Events",
"file": "multiple_popup_events",
"path": "popups"
}, {
"title": "Popup Expressions",
"desc": "Popups with Expressions",
"file": "popup_expressions",
"path": "popups"
}]
}, {
"title": "Map Layout",
Expand Down
13 changes: 3 additions & 10 deletions docs/developer-center/guides/02-Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,21 @@ This guide is intended for those who are using CARTOframes for the first time an

CARTOframes can be installed with [`pip`](https://pypi.org/project/pip/) by simply typing one of the following commands to do a system install:

To install the latest beta release (recommended), use the `--pre` flag:

```bash
$ pip install cartoframes --pre
```

To install the latest stable version (soon to be deprecated):
To install the latest stable version:

```bash
$ pip install cartoframes
```

To install a specific version, for example, let's say the 1.0b7 version:
To install a specific version, let's say the 1.0b7 version:

```bash
$ pip install cartoframes==1.0b7
```


### Install CARTOframes in a Jupyter Notebook

In the CARTOframes Developer Center, all of the examples are in a [Jupyter Notebook](https://jupyter.org/). If you aren't familiar with Jupyter Notebooks, we recommended reading the [beginner documentation](https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html) to get familiar with the environment.
In the CARTOframes Developer Center, all of the examples are created with [Jupyter Notebooks](https://jupyter.org/). If you aren't familiar with Jupyter Notebooks, we recommend reading the [beginner documentation](https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html) to get familiar with the environment.

To install CARTOframes through a Jupyter Notebook, run this command:

Expand Down
26 changes: 16 additions & 10 deletions docs/developer-center/guides/04-Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Hi! Glad to see you made it to the Quickstart guide! In this guide you are intro
Before you get started, we encourage you to have CARTOframes installed so you can get a feel for the library by using it:

```
pip install --pre cartoframes
pip install cartoframes
```

For additional ways to install CARTOframes, check out the [Installation Guide](/developers/cartoframes/guides/Installation).
Expand Down Expand Up @@ -191,12 +191,12 @@ Map(Layer(stores_gdf))

Great! You have a map!

With the stores plotted on the map, you now have a better sense about where each one is. To continue your exploration, you want to know which stores earn the most yearly revenue. To do this, you can use the [`size_continuous_layer`](/developers/cartoframes/examples/#example-size-continuous-layer) visualization layer:
With the stores plotted on the map, you now have a better sense about where each one is. To continue your exploration, you want to know which stores earn the most yearly revenue. To do this, you can use the [`size_continuous_style`](/developers/cartoframes/examples/#example-size-continuous-style) visualization layer:

```python
from cartoframes.viz.helpers import size_continuous_layer
from cartoframes.viz import Map, Layer, size_continuous_style

Map(size_continuous_layer(stores_gdf, 'revenue', 'Annual Revenue ($)'))
Map(Layer(stores_gdf, size_continuous_style('revenue', 'Annual Revenue ($)'))
```

<div class="example-map">
Expand All @@ -210,7 +210,7 @@ Map(size_continuous_layer(stores_gdf, 'revenue', 'Annual Revenue ($)'))
</iframe>
</div>

Good job! By using the [`size continuous visualization layer`](/developers/cartoframes/examples/#example-size-continuous-layer) you can see right away where the stores with higher revenue are. By default, visualization layers also provide a popup with the mapped value and an appropriate legend.
Good job! By using the [`size continuous visualization style`](/developers/cartoframes/examples/#example-size-continuous-style) you can see right away where the stores with higher revenue are. By default, visualization styles also provide a popup with the mapped value and an appropriate legend.

### Create your areas of influence

Expand Down Expand Up @@ -2193,9 +2193,14 @@ isochrones_gdf.head()
Great! Let's see the result on a map:

```python
from cartoframes.viz.helpers import color_continuous_layer
from cartoframes.viz import color_continuous_style

Map(color_continuous_layer(isochrones_gdf, 'sum_total_pop', 'Population'))
Map(
Layer(
isochrones_gdf,
style=color_continuous_style('sum_total_pop', 'Population')
)
)
```

<div class="example-map">
Expand All @@ -2213,7 +2218,7 @@ We can see that the area of influence of the store on the right, is the one with

```python
stores_gdf['rev_pop'] = stores_gdf['revenue']/isochrones_gdf['sum_total_pop']
Map(size_continuous_layer(stores_gdf, 'rev_pop', 'Revenue per person ($)'))
Map(Layer(stores_gdf, size_continuous_style('rev_pop', 'Revenue per person ($)')))
```

<div class="example-map">
Expand Down Expand Up @@ -2249,9 +2254,10 @@ Now, let's visualize them and add widgets to them so people are able to see some

```python
result_map = Map([
color_continuous_layer('starbucks_isochrones', 'sum_total_pop', 'Population', stroke_width=0, opacity=0.7),
size_continuous_layer('starbucks_stores', 'rev_pop', 'Revenue per person ($)', stroke_color='white', widget=True)
Layer('starbucks_isochrones', color_continuous_style('sum_total_pop', 'Population', stroke_width=0, opacity=0.7)),
Layer('starbucks_stores', size_continuous_style('rev_pop', 'Revenue per person ($)', stroke_color='white', widget=True))
])

result_map
```

Expand Down

0 comments on commit fcbee1c

Please sign in to comment.