Wild fish catch by gear type, World

Author

math4mad

load pacakge

Code
include("utils.jl")
[ Info: loading success

2. load data->dataframe

Code
df=@pipe CSV.File("./data/fish-catch-gear-type.csv")|>DataFrame|>DataFrame|>coalesce.(_, 0.0)|>rename!(_,"pelagic trawl"=>:pelagic_trawl)
13730×11 DataFrame
13705 rows omitted
Row Entity Code Year unknown_gear other_gear longline gillnet small_scale purse_seine pelagic_trawl bottom_trawl
String Any Int64 Float64 Float64 Float64 Float64 Float64 Float64 Float64 Float64
1 Albania ALB 1995 1.21382 135.643 0.0 0.0 39.7734 54.0707 104.631 1120.05
2 Albania ALB 1996 16.5429 209.023 0.0 0.0 50.4084 84.432 163.963 1804.86
3 Albania ALB 1997 14.2151 113.616 0.0 0.0 13.3192 38.8843 75.6516 810.648
4 Albania ALB 1998 14.2151 219.064 0.0 0.0 10.9106 88.8256 173.728 1897.43
5 Albania ALB 1999 14.2151 227.661 0.0 0.0 11.3388 92.3117 180.907 1972.6
6 Albania ALB 2011 634.994 0.0 0.0 0.0 21.7128 143.804 0.0 3144.62
7 Albania ALB 2012 1499.1 0.0 0.0 0.0 45.1773 339.495 0.0 7423.87
8 Albania ALB 2013 1561.1 0.0 0.0 0.0 47.0043 353.535 0.0 7730.9
9 Albania ALB 2014 1869.72 0.0 0.0 0.0 71.146 282.188 0.0 6170.72
10 Albania ALB 2015 1149.99 0.0 0.0 0.0 33.2955 273.578 0.0 5982.43
11 Albania ALB 2016 1447.69 0.0 0.0 0.0 51.6242 251.592 0.0 5501.66
12 Albania ALB 2017 1566.67 0.0 0.0 0.0 58.2399 249.588 0.0 5457.85
13 Albania ALB 2018 899.878 0.0 0.0 0.0 17.0815 299.842 0.0 6556.76
13719 Yemen YEM 1999 0.0 10150.0 0.0 0.0 1.73005e5 0.0 0.0 89861.3
13720 Yemen YEM 2000 0.0 11239.5 0.0 0.0 1.47774e5 0.0 0.0 89681.5
13721 Yemen YEM 2001 0.0 10217.8 0.0 0.0 1.85588e5 0.0 0.0 1.02895e5
13722 Yemen YEM 2002 0.0 9503.93 0.0 0.0 2.49449e5 0.0 0.0 1.14498e5
13723 Yemen YEM 2003 0.0 26166.0 0.0 0.0 3.29698e5 0.0 0.0 1.03919e5
13724 Yemen YEM 2004 0.0 32574.7 0.0 0.0 372192.0 0.0 0.0 1.0894e5
13725 Yemen YEM 2005 0.0 30072.7 0.0 0.0 351902.0 0.0 0.0 95306.5
13726 Yemen YEM 2006 0.0 30707.2 0.0 0.0 3.45725e5 0.0 0.0 86286.5
13727 Yemen YEM 2007 0.0 27540.5 0.0 0.0 2.61181e5 0.0 0.0 74653.9
13728 Yemen YEM 2008 0.0 20552.1 0.0 0.0 1.80339e5 0.0 0.0 43331.4
13729 Yemen YEM 2009 0.0 24330.6 0.0 0.0 2.29675e5 0.0 0.0 57511.8
13730 Yemen YEM 2010 0.0 28806.0 0.0 0.0 2.64376e5 0.0 0.0 93367.3

3. data processing

Code
df=@chain df begin
   @group_by(Year)
   @summarize(unknown_gear=sum(unknown_gear),
              other_gear=sum(other_gear),
              longline=sum(other_gear),
              gillnet=sum(gillnet),
              small_scale=sum(small_scale),
              purse_seine=sum(purse_seine),
              pelagic_trawl=sum(pelagic_trawl),
              bottom_trawl=sum(bottom_trawl)
    )
   @ungroup
   @pivot_longer(_, unknown_gear:bottom_trawl,names_to = gear_type, values_to =weight)
end
552×3 DataFrame
527 rows omitted
Row Year gear_type weight
Int64 String Float64
1 1995 unknown_gear 1.06338e7
2 1996 unknown_gear 1.0397e7
3 1997 unknown_gear 1.1286e7
4 1998 unknown_gear 1.08899e7
5 1999 unknown_gear 1.15815e7
6 2011 unknown_gear 1.05883e7
7 2012 unknown_gear 1.07134e7
8 2013 unknown_gear 1.0431e7
9 2014 unknown_gear 1.19992e7
10 2015 unknown_gear 1.54834e7
11 2016 unknown_gear 1.20867e7
12 2017 unknown_gear 1.6716e7
13 2018 unknown_gear 1.57526e7
541 1994 bottom_trawl 5.43778e7
542 2000 bottom_trawl 5.18786e7
543 2001 bottom_trawl 5.23496e7
544 2002 bottom_trawl 5.20457e7
545 2003 bottom_trawl 5.00434e7
546 2004 bottom_trawl 5.05469e7
547 2005 bottom_trawl 4.82271e7
548 2006 bottom_trawl 4.84797e7
549 2007 bottom_trawl 4.7881e7
550 2008 bottom_trawl 4.76333e7
551 2009 bottom_trawl 4.80774e7
552 2010 bottom_trawl 4.89898e7

4. plot

Code
@rput df
function plot_arestack_r()
 R"""
    library(ggplot2)
    library(ggthemes)
    library(viridis)
    ggplot(df, aes(x=Year, y=weight, fill=gear_type)) + 
    geom_area(alpha=0.6 , size=.5, colour="white")+scale_fill_viridis(discrete = T)+theme_wsj()
 """
end
plot_arestack_r()
┌ Warning: RCall.jl: Warning: package ‘ggthemes’ was built under R version 4.2.3
└ @ RCall ~/.julia/packages/RCall/gOwEW/src/io.jl:172
┌ Warning: RCall.jl: Loading required package: viridisLite
└ @ RCall ~/.julia/packages/RCall/gOwEW/src/io.jl:172
┌ Warning: RCall.jl: Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
│ ℹ Please use `linewidth` instead.
└ @ RCall ~/.julia/packages/RCall/gOwEW/src/io.jl:172
(a) different gear fihsing amount
RObject{VecSxp}
(b)
Figure 1