我在R中使用E = csvread('Experiment_at_10_45_1.csv');
[signal_rows, signal_columns] = size(E);
t=(1:signal_rows)/128; %128 samples per second
%% SNR plot for down frequency
plot(t,E(:,13),'k')
成功绘制了我的数据。但是,当我选择将y轴和x轴放在log10缩放中时,y轴上的第一个刻度(0.01)进一步分开交叉点比x轴上的第一个刻度线(0.01)。我需要x轴具有相同的"缩放"作为y轴。
这是我的代码。还有数据(使用sep =" \ t")。以及图表如何找我的图像。对不起,数据在外部链接上,我无法弄清楚如何将其作为可重现的数据提供给您!
ggplot()
答案 0 :(得分:1)
您忘记在limits
和scale_x_log10
中添加scale_y_log10
:
FILE1 <- read.delim("example.txt", sep="\t", header = TRUE)
EXAMPLE_PLOT <- ggplot(FILE1, aes_string(x = colnames(FILE1)[1], y = colnames(FILE1)[2])) +
geom_point(size=4) +
ggtitle("EXAMPLE_PLOT") +
theme(plot.title = element_text(family="Calibri", color="black",
face="bold", size = 32, hjust=0)) +
theme(plot.background= element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())+
theme(panel.background = element_blank())+
theme(axis.line.x = element_line(color="black", size = 1),
axis.line.y = element_line(color="black", size = 1))+
theme(axis.ticks = element_line(color="black", size = 1))+
theme(axis.ticks.length = unit(0.3,"cm"))+
theme(axis.title = element_text(family = "Calibri",
color="black", size=17, face="bold"))+
theme(axis.text.x = element_text(family = "Calibri", color="black",
size=14, face="bold"),
axis.text.y = element_text(family = "Calibri", color="black",
size=14, face="bold"))+
scale_x_log10(breaks=c(.01, .1, 1, 10, 100), limits = c(0.01,10))+
scale_y_log10(breaks=c(.01, .1, 1, 10, 100), limits = c(0.01,10))+
geom_smooth(method=lm)
EXAMPLE_PLOT