简体   繁体   English

如何使 y 轴线与 theme_clean() 中的 x 轴线相匹配?

[英]How can I make y-axis lines that match the x-axis lines from theme_clean()?

I'm going to be producing a lot of visuals for a report.我将为报告制作大量视觉效果。 My boss really likes the theme_clean() horizontal lines but wants me to add the same lines to the x-axis.我的老板真的很喜欢theme_clean()水平线,但希望我在 x 轴上添加相同的线。 Is there an easy way to do this?是否有捷径可寻?

Here is my code这是我的代码

library(ggplot2)
library(ggthemes)

ggplot(mtcars, aes(x = mpg)) + 
  geom_point(aes(y = hp)) + 
  theme_clean(base_size=18)

在此处输入图像描述

How can I get the same style for my x-axis ticks (going vertical).如何为我的 x 轴刻度(垂直)获得相同的样式。

Best.最好的。

Try this.尝试这个。 Simply typing theme_clean into the console shows you the default values used by theme_clean for panel.grid.major.y which we then can use to set the values for panel.grid.major.x accordingly using theme() :只需在控制台中输入theme_clean显示theme_cleanpanel.grid.major.y使用的默认值,然后我们可以使用theme()相应地设置panel.grid.major.x的值:

library(ggplot2)
library(ggthemes)

ggplot(mtcars, aes(x = mpg)) + 
  geom_point(aes(y = hp)) + 
  theme_clean(base_size=18) + 
  theme(panel.grid.major.x = element_line(colour = "gray", linetype = "dotted"))

Created on 2020-04-07 by the reprex package (v0.3.0)代表 package (v0.3.0) 于 2020 年 4 月 7 日创建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 R ggplot2:如何使x轴线不与y轴重叠? - R ggplot2: how to make x-axis lines not overlapping y-axis? 如何在ggplot2中使y轴与x轴相交为0? - How do I make the y-axis intersect the x-axis at 0 in ggplot2? 生成多条线的折线图:X 轴无序且 y 轴刻度不等间隔 - Producing line graphs with multiple lines: X-axis is out of order and y-axis scales are not in even intervals 如何使用 ggplot 在 x 轴上绘制日期,在 y 轴上绘制价格表和属性? - How can I plot date on x-axis and price list on y-axis and attribute by using ggplot? 如何在ggplot2中独立控制y轴刻度和x轴刻度? - How can I control y-axis ticks and x-axis ticks independently in ggplot2? 如何从绘图中完全去除x轴(和y轴),并使用Python或R编程在某些点绘制切线? - How to totally remove x-axis (and y-axis) from the plot and also draw tangent lines at certain points using Python or R-programming? 如何在GGPLOT theme_classic()中启用x轴和y轴线 - How to enable x-axis and y-axis line in GGPLOT theme_classic() 如何扩展x轴和y轴并缩小ggthemes :: theme_tufte()中的差距 - How to extend x-axis and y-axis and narrow the gap in ggthemes::theme_tufte() 如何固定x轴和y轴比例 - how to fix x-axis and y-axis scale 在R图中,如何使x轴的长度比y轴长几倍? - In R plots, how can we make the length of an x-axis several times longer than the y-axis?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM