如何在轴

时间:2016-01-17 18:27:55

标签: r plot

我使用函数plot()绘制图形,例如my plot

actual graph

如何更改此图表的 x轴的比例?我想要的是这个情节desired plot

expected graph

请注意,在所需的绘图中,较大值的比例已被缩放"进行。

以下代码不起作用,因为它只能更改轴上的刻度线,并且它不能缩小"缩小"大价值的规模。

plot( ,xaxt="n")
axis(side = 1 , at = c(.....), labels=c(......))

以下是我的数据集的一部分

>mydata$x
8030.476314, 8025.266041, 6550.710885, 5970.38876, 7264.607226, 
8105.388755, 631.6998778, 473.6989113, 434.0199707, 32448.60764, 
1287.084562, 6013.410273, 6022.650485, 5680.881734, 5749.552012, 
5885.51966, 6648.236012, 338.2700053, 3621, 16644.97723, 14300.96105, 
16137.212, 29490.37328, 6481.776993, 7268.522198, 7319.007536, 
5910.998347, 6533, 4114.221069, 5042.311631, 5037.559385, 5248.874105, 
5341.273234, 5351.568666, 5350.197626, 5403, 27171.96611, 25556.85006, 
1861.568555, 2264.092687, 2637.562323, 3505, 4246.485974, 4324.875638, 
4790.143909, 4884.720925, 4858.347495, 5034.098131, 759.6628005, 
737.7571713, 575.7047176, 797.4755344, 815.2221702, 934.3713607

> mydata$y
0.20355, 0.25855, 0.2045, 0.17305, 0.1853, 0.19565, 0.19155, 
0.18925, 0.18995, 0.17815, 0.18025, 0.09277798586, 0.1117, 0.1287, 
0.131, 0.14255, 0.1434, 0.22865, 0.2305, 0.21905, 0.21675, 0.21135, 
0.2058, 0.20925, 0.18565, 0.12515, 0.157, 0.14635, 0.15985, 0.20535, 
0.1632, 0.164766778365, 0.0702, 0.08465, 0.10045, 0.08295, 0.097, 
0.09065, 0.10305, 0.14659401364, 0.133299780225, 0.15775, 0.1511, 
0.1229, 0.14935, 0.1631, 0.18, 0.16755, 0.08455, 0.0826, 0.10935, 
0.11775, 0.1038, 0.11935, 0.114, 0.09783246265, 0.0806, 0.19775, 
0.12425, 0.1204, 0.10685, 0.11185, 0.10825, 0.1287, 0.1169, 0.1164, 
0.21265, 0.21555, 0.2395, 0.19205, 0.10138124242, 0.0944, 0.11605 

有人知道如何实现这个目标吗?

2 个答案:

答案 0 :(得分:0)

日志转换是否可以接受? (以下代码)

这是左边的原始数据和右边的日志转换相同的数据

same data with a log transformation

df <- data.frame(y = c(0:6), x = c(0.01, 0.1, 0.9, 1, 25, 34.9, 56.2))
plot(df$x, df$y)

plot(log(df$x), df$y)

答案 1 :(得分:0)

解决方法是将og=x添加到plot()函数中,将x轴设置为对数刻度。