您的图表是合理的,但需要进行一些改进,包括标题,轴标签和完整的国家/地区标签。如果您的目标是强调德国是唯一在观察期内死亡率上升的国家,那么一种简单的方法是在图中突出显示此线,方法是使用更粗的线线型或Alpha透明度。您还可以使用条形图来扩大时间序列图,该条形图显示死亡率随时间的变化,从而使时间序列线的复杂性降低为单一变化度量。
这是使用ggplot
in 生成这些图的方法R
:
library(tidyr);
library(dplyr);
library(ggplot2);
#Create data frame in wide format
DATA_WIDE <- data.frame(Year = 1927L:1937L,
DE = c(10.9, 11.2, 11.4, 10.4, 10.4, 10.2, 10.8, 10.6, 11.4, 11.7, 11.5),
FR = c(16.5, 16.4, 17.9, 15.6, 16.2, 15.8, 15.8, 15.1, 15.7, 15.3, 15.0),
BE = c(13.0, 12.8, 14.4, 12.8, 12.7, 12.7, 12.7, 11.7, 12.3, 12.2, 12.5),
NL = c(10.2, 9.6, 10.7, 9.1, 9.6, 9.0, 8.8, 8.4, 8.7, 8.7, 8.8),
DEN = c(11.6, 11.0, 11.2, 10.8, 11.4, 11.0, 10.6, 10.4, 11.1, 11.0, 10.8),
CH = c(12.4, 12.0, 12.5, 11.6, 12.1, 12.2, 11.4, 11.3, 12.1, 11.4, 11.3),
AUT = c(15.0, 14.5, 14.6, 13.5, 14.0, 13.9, 13.2, 12.7, 13.7, 13.2, 13.3),
CZ = c(16.0, 15.1, 15.5, 14.2, 14.4, 14.1, 13.7, 13.3, 13.5, 13.3, 13.3),
PL = c(17.3, 16.4, 16.7, 15.6, 15.5, 15.0, 14.2, 14.4, 14.0, 14.2, 14.0));
#Convert data to long format
DATA_LONG <- DATA_WIDE %>% gather(Country, Measurement, DE:PL);
#Set line-types and sizes for plot
#Germany (DE) is the fifth country in the plot
LINETYPE <- c("dashed", "dashed", "dashed", "dashed", "solid", "dashed", "dashed", "dashed", "dashed");
SIZE <- c(1, 1, 1, 1, 2, 1, 1, 1, 1);
#Create time-series plot
theme_set(theme_bw());
PLOT1 <- ggplot(DATA_LONG, aes(x = Year, y = Measurement, colour = Country)) +
geom_line(aes(size = Country, linetype = Country)) +
scale_size_manual(values = SIZE) +
scale_linetype_manual(values = LINETYPE) +
scale_x_continuous(breaks = 1927:1937) +
scale_y_continuous(limits = c(0, 20)) +
labs(title = "Annual Time Series Plot: Death Rates over Time",
subtitle = "Only Germany (DE) trends upward from 1927-37") +
xlab("Year") + ylab("Crude Death Rate\n(per 1,000 population)");
#Create new data frame for differences
DATA_DIFF <- data.frame(Country = c("DE", "FR", "BE", "NL", "DEN", "CH", "AUT", "CZ", "PL"),
Change = as.numeric(DATA_WIDE[11, 2:10] - DATA_WIDE[1, 2:10]));
#Create bar plot
PLOT2 <- ggplot(DATA_DIFF, aes(x = reorder(Country, - Change), y = Change, colour = Country, fill = Country)) +
geom_bar(stat = "identity") +
labs(title = "Bar Plot: Change in Death Rates from 1927-37",
subtitle = "Only Germany (DE) shows an increase in death rate") +
xlab(NULL) + ylab("Change in crude Death Rate\n(per 1,000 population)");
这导致以下情况:
注意:我知道OP旨在强调自1932年德国趋势开始上升以来的死亡率变化。在我看来,这有点像采摘樱桃,当选择时间间隔以获得特定趋势时,我发现这是可疑的。因此,我查看了整个数据范围内的间隔,这与OP的比较有所不同。