Biology
1 Deaths from COVID-19 in Brazil and total cases by state - 2023 update (EM13MAT406, EM13CNT303, EM13CHS101)
<- "https://raw.githubusercontent.com/wcota/covid19br/refs/heads/master/cases-brazil-cities.csv" # defines the link to the data
url <- read.csv(url) # read the data file
data library(magrittr)
<- plot_ly(
p
data,x = ~totalCases,
y = ~deaths,
color = ~state,
frame = ~state, # Frame for the animation by year
text = ~city,
hoverinfo = "text",
type = 'scatter',
mode = 'markers',
marker = list(sizemode = 'diameter', opacity = 0.7)
%>%
) layout(
title = "COVID-19 deaths in Brazil (2023 update)",
xaxis = list(title = "total cases", type = "log"),
yaxis = list(title = "Deaths", type = "log"),
showlegend = FALSE
%>%
) animation_opts(
frame = 500, # Animation speed
transition = 0,
redraw = FALSE
) p
Suggestions:
Try modifying the graph, using/replacing the commands below in the code snippet:
= list(title = "Total Cases", type = "log", range = c(0, 7)), # Change in the scale of the X axis
xaxis = list(title = "Deaths", type = "log", range = c(0, 6)), # Change in the scale of the Y axis yaxis
2 Photosynthesis rate with variation in light intensity (EM13CNT101, EM13CNT102)
These parameters define a hyperbolic relationship, which can be linearized (double-reciprocal graph). Click in one data point to show its position in the other graph.
library(plotly)
library(crosstalk)
library(magrittr)
# Create some sample data
= 1:20 # Light intensity (x) ranging from 0 to 20
x = 10*x/(0.5+x) # photosynthesis rate (y) using the function y = a * x / (b + x)
y
# Building the dataset
<- data.frame(x,y,
data group = sample(c("A", "B")))
# Creating a crosstalk between graphs (crosstalk shared data frame)
<- SharedData$new(data)
shared_data
# Creating the first graph
<- plot_ly(shared_data, x = ~x, y = ~y, color = ~group, type = "scatter", size=5, mode = "markers") %>%
p1 layout(title = "Graph 1") %>%
highlight()
# Creating the second graph
<- plot_ly(shared_data, x = ~1/x, y = ~1/y, color = "orange", type = "scatter", size= 5, mode = "markers") %>%
p2 layout(title = "Photosynthesis rate with light intensity - regular and double-reciprocal graphs") %>%
highlight()
# Arranging the graphs side by side
subplot(p1, p2)
library(magrittr)
Suggestions:
Try it out to modify the graph, using/replacing alternatively the commands below in the code snippet:
1. The use of the `crosstalk` library allows communication between the graphs presented. To illustrate, try clicking on a point on the regular graph, and observe its position on the double-reciprocal graph.