[英]Change the x-axis and y-axis spacing using the ggplot package in R
I am making a graph in ggplot, but I cannot improve the visualization of the abscissa and ordinates.我正在 ggplot 中制作图表,但无法改善横坐标和纵坐标的可视化。
In the abscissa (X) the years are very close and in the ordinate I would like to stretch vertically a little more.在横坐标 (X) 中,年份非常接近,在纵坐标中,我想垂直拉伸一点。 What arguments can I add to the code to improve it?
我可以在代码中添加什么 arguments 来改进它?
follow my code and the result of it:按照我的代码及其结果:
IQA_total<-quali3%>%
select(Estacao, Ano2, IQA)
ggplot(IQA_total, aes(x=Ano2, y=IQA, group = 1)) +
geom_point() +
geom_line(color="steelblue") +
scale_x_date(breaks = '1 years', date_labels = '%Y') +
facet_wrap(~Estacao) +
labs(subtitle = "Mean Annual IQA",
x = "Year",
y = "Mean IQA") +
theme_bw(6)+
theme_minimal() +
theme(text = element_text(size = 8))+
theme(axis.text.x = element_text(angle = 90))
chart result图表结果
Edit update编辑更新
I try scales="free", but the result no well我尝试 scales="free",但结果不好
enter image description here在此处输入图像描述
update 2更新 2
dput(head(IQA_total))输入(头(IQA_total))
structure(list(Dist_Foz = c("334", "334", "0", "0", "0", "0"),
Altitude = c("173", "173", "143", "143", "143", "143"), Classe = c("2",
"2", "2", "2", "2", "2"), Ano = c(2018, 2018, 2005, 2005,
2005, 2005), Estacao = c("00MS023AQ2334", "00MS023AQ2334",
"00MS23AC2000", "00MS23AC2000", "00MS23AC2000", "00MS23AC2000"
), Ano2 = structure(c(17532, 17897, 12784, 12784, 13149,
13149), class = "Date"), IQA = c(77, 78, 50, 49, 61, 38)), row.names = c(NA,
-6L), groups = structure(list(Estacao = c("00MS023AQ2334", "00MS023AQ2334",
"00MS23AC2000", "00MS23AC2000"), Dist_Foz = c("334", "334", "0",
"0"), Altitude = c("173", "173", "143", "143"), Classe = c("2",
"2", "2", "2"), Ano = c(2018, 2018, 2005, 2005), Ano2 = structure(c(17532,
17897, 12784, 13149), class = "Date"), .rows = structure(list(
1L, 2L, 3:4, 5:6), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 4L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
Try this as r2Evans points out with 2 years breaks试试这个,正如 r2Evans 指出的那样,有 2 年的休息时间
IQA_total<-quali3%>%
select(Estacao, Ano2, IQA)
ggplot(IQA_total, aes(x=Ano2, y=IQA, group = 1)) +
geom_point() +
geom_line(color="steelblue") +
scale_x_date(breaks = '2 years', date_labels = '%Y') +
facet_wrap(~Estacao) +
labs(subtitle = "Mean Annual IQA",
x = "Year",
y = "Mean IQA") +
theme_bw(6)+
theme_minimal() +
theme(text = element_text(size = 8))+
theme(axis.text.x = element_text(angle = 90))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.