R Tutorial : Constructing rbokeh Layers (Part 2)
Key Takeaways
Constructs rbokeh layers for interactive data visualization in R
Full Transcript
now that you have became familiar with the concept of layers in our bokeh and how the plots are constructed let's see some more layers arboque provides a wide variety of functions which are also known as layers basically all the layers start with ly underscore followed by the type of the layer in this course we will focus on some of the most common layers mainly the ones to create scatter plots lines bar charts histograms now let's see an example using a subset of the gapminder data in 1982. by filtering the gapminder data by year equal equal 1982 you can see that the resulting data frame contains 142 entries with one row per country now suppose you want to see the relation between life expectancy and gdp per capita in 1982 a scatter plot will be a good choice to see all the data points first you need to initialize a figure then you need to create a layer l-y points and pass the required arguments gdp per capita on the x-axis life expectancy on the y-axis and the filter data frame that underscore 1982 to the data argument notice that the resulting plot includes a point for each country and it shows that there could be a relation between the life expectancy and the gdp per capita now as you saw the lines layer and the points layer you will see how to combine both in one figure let's take the records of australia and new zealand by filtering the gap minder data using the continent equal equal oceania the resulting data frame will include the data of the two countries in all the years now we would like to see the change of gdp per capita in the two countries over time to plot multiple layers you can pass the data underscore oceania to the data argument in figure this will tell all the subsequent layers to use this data frame instead of specifying the data in each layer independently which is still a valid option then you can add a lines layer using ly underscore lines you will need to specify the x argument as the year and the y as the gdp per capita and you can use the color to distinguish between the countries in the next chapter you will learn more about the use of colors in different layers to add markers you can add a points layer by using the pipe operator and adding ly underscore points with similar arguments notice that the legend location is specified as bottom right to change the default collision position this is one of the figure attributes and you will learn more about them in chapter 2. the resulting plot shows you how the gap in the gdp per capita increased with time between the two countries now it's time to try more
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/interactive-data-visualization-with-rbokeh at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Now that you have become familiar with the concept of layers in rbokeh, and how the plots are constructed, let's see more layers.
rbokeh provides a wide variety of functions, which are also known as layers.
Basically all the layers start with ly - underscore, followed by the type of the layer
In this course we'll focus on a some of the most common layers, mainly the ones to create:
* scatter plots
* lines
* bar plots
* histograms
Now let's see an example using a subset of the gapminder data in one 1982.
By filtering the gapminder data by year == 1982, You can see that the resulting dataframe contains 142 entries, with one row per country.
Now suppose you want to see the relation between lifeExp and gdpPercap in 1982, a scatter plot will be a good choice to see all the data points.
First you need to initialize a figure().
Then you need to create a layer ly_points and pass the required arguments:
- gdpPercap on the x axis
- lifeExp on the y axis
- and the filtered dataframe dat_1982 to the data argument
Notice that the resulting plot includes a point for each country and it shows that there could be a relation between the lifeExp and the the gdp per capita.
Now as you saw the lines layer and the points layer, we will see how to combine both in one figure.
Let's take the records of Australia and Newzealand by filtering the gapminder data using the continent == oceania.
The resulting dataframe will include the data of the two countries in all the years.
Now we would like to see the change of gdp per capita in the two countries over time
to plot multiple layers:
- you can pass the data_oceania to the data argument in figure(). This will tell all the subsequent layers to use this dataframe instead of specifying the data in
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
🎓
Tutor Explanation
DeepCamp AI