Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
woRkflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom Rushby
woRkflow
Commits
c707a074
Commit
c707a074
authored
4 years ago
by
Tom Rushby
Browse files
Options
Downloads
Patches
Plain Diff
fix strip bar plot single LA & year.
parent
7de3a464
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
howTo/openGeogAPI/local_auth_ghg_plots.R
+35
-5
35 additions, 5 deletions
howTo/openGeogAPI/local_auth_ghg_plots.R
with
35 additions
and
5 deletions
howTo/openGeogAPI/local_auth_ghg_plots.R
+
35
−
5
View file @
c707a074
...
@@ -134,6 +134,11 @@ ghg_subset <- function(dt, auth_area = "Southampton"){
...
@@ -134,6 +134,11 @@ ghg_subset <- function(dt, auth_area = "Southampton"){
}
}
# Construct plots ----
# Construct plots ----
plotCaption
=
paste0
(
"Emissions data: Department for Business, Energy & Industrial Strategy"
,
"\nUK local authority and regional carbon dioxide emissions national statistics: 2005 to 2018"
,
"\nVisualisation: t.w.rushby@soton.ac.uk | energy.soton.ac.uk"
)
# Emissions by year for each local authority
i
<-
1
i
<-
1
plotNames
<-
list
()
plotNames
<-
list
()
...
@@ -141,10 +146,6 @@ for (auth_area in las_to_load) {
...
@@ -141,10 +146,6 @@ for (auth_area in las_to_load) {
plotName
<-
paste0
(
"laemissions_by_year_"
,
gsub
(
"[[:space:]]"
,
"_"
,
auth_area
))
plotName
<-
paste0
(
"laemissions_by_year_"
,
gsub
(
"[[:space:]]"
,
"_"
,
auth_area
))
plotCaption
=
paste0
(
"Emissions data: Department for Business, Energy & Industrial Strategy"
,
"\nUK local authority and regional carbon dioxide emissions national statistics: 2005 to 2018"
,
"\nVisualisation: t.w.rushby@soton.ac.uk | energy.soton.ac.uk"
)
plotTitle
=
paste0
(
"Greenhouse gas emissions by source: "
,
auth_area
)
plotTitle
=
paste0
(
"Greenhouse gas emissions by source: "
,
auth_area
)
plot_data1
<-
ghg_subset
(
pc_detail_plot
,
auth_area
=
auth_area
)
plot_data1
<-
ghg_subset
(
pc_detail_plot
,
auth_area
=
auth_area
)
...
@@ -176,8 +177,9 @@ i <- i+1
...
@@ -176,8 +177,9 @@ i <- i+1
print
(
plotNames
)
print
(
plotNames
)
#
B
y local authority
#
Emissions b
y local authority
years_to_plot
<-
c
(
2005
,
2018
)
years_to_plot
<-
c
(
2005
,
2018
)
plot_year
<-
2018
for
(
plot_year
in
years_to_plot
)
{
for
(
plot_year
in
years_to_plot
)
{
...
@@ -210,6 +212,34 @@ for(plot_year in years_to_plot) {
...
@@ -210,6 +212,34 @@ for(plot_year in years_to_plot) {
}
}
# Emissions for single local authority
plot_data1
<-
pc_detail_plot
%>%
filter
(
Year
==
plot_year
&
Name
==
auth_area
)
plot_data2
<-
pc_totals_plot
%>%
filter
(
Year
==
plot_year
&
Name
==
auth_area
)
x_min
<-
floor
(
min
(
plot_data2
$
value
))
x_max
<-
ceiling
(
sum
(
plot_data2
$
value
))
plot
<-
ggplot
()
+
geom_col
(
data
=
plot_data1
,
aes
(
x
=
Name
,
y
=
value
,
fill
=
variable
),
position
=
"stack"
)
+
#geom_col(data = plot_data2, aes(x = Name, y = value, colour = variable), fill = NA, position = "stack") +
geom_hline
(
yintercept
=
0
,
lwd
=
0.4
,
colour
=
"black"
,
linetype
=
"dashed"
)
+
coord_flip
(
ylim
=
c
(
x_min
,
x_max
))
+
scale_y_continuous
(
breaks
=
x_min
:
x_max
)
+
scale_color_manual
(
values
=
totals_pal
)
+
scale_fill_manual
(
values
=
detailed_pal
)
+
theme_minimal
()
+
labs
(
y
=
"Emissions per capita (tonnes of carbon dioxide/person)"
)
+
theme
(
axis.text.y
=
element_blank
(),
axis.title.y
=
element_blank
(),
axis.ticks.y
=
element_blank
(),
#axis.title.x = element_blank(),
panel.grid.major.y
=
element_blank
(),
legend.position
=
"none"
)
ggplotly
(
plot
)
ggplot
()
+
ggplot
()
+
geom_col
(
data
=
plot_data1
,
aes
(
x
=
Name
,
y
=
value
,
fill
=
variable
),
position
=
"stack"
)
+
geom_col
(
data
=
plot_data1
,
aes
(
x
=
Name
,
y
=
value
,
fill
=
variable
),
position
=
"stack"
)
+
geom_col
(
data
=
plot_data2
,
aes
(
x
=
Name
,
y
=
value
,
colour
=
variable
),
fill
=
"none"
,
position
=
"stack"
)
+
geom_col
(
data
=
plot_data2
,
aes
(
x
=
Name
,
y
=
value
,
colour
=
variable
),
fill
=
"none"
,
position
=
"stack"
)
+
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment