[英]How to get customize the x-axis in ggplot2 package?
I am currently using the ggplot2
package to plot a quantity by each year and I want to make it so that only every other year shows up in the x-axis instead of every year, like it currently is. 目前,我正在使用
ggplot2
软件包按年绘制数量,并且希望将其绘制为仅每隔一年在x轴上显示一次,而不是像现在这样显示每年。 So how would I go about doing this in the ggplot2
package. 因此,我将如何在
ggplot2
软件包中执行此ggplot2
。
I am not sure how to show plots in stack overflow but my current plot has all the years from 1996 to 2011 right next to each other, but I only want to show every other year from 1996 so that all the tick marks are more spread apart from each other. 我不确定如何显示堆栈溢出的图,但是我当前的图显示1996年到2011年之间的所有年份彼此相邻,但是我只想显示1996年以后的每一年,以便所有刻度线都更分散彼此。
You should include a relevant example with code in your question. 您应该在问题中包含代码的相关示例。 However, making a few assumptions from your description, I'd guess that you might try using the scales package and including the following
但是,根据您的描述做出一些假设,我想您可能会尝试使用scales软件包,其中包括以下内容
library(scales)
scale_x_date(labels=date_format("%Y"), breaks=date_breaks("2 year"))
with your ggplot statements. 与您的ggplot语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.