I'm struggling with a plot. I have a vector "a":
我在苦苦挣扎。我有一个矢量“a”:
h1 h2 h3 h4
1.000 0.880 0.746 0.761
These are data of normalized concentration of an element in a soil profile.
这些是土壤剖面中元素的归一化浓度的数据。
I would like to have on the x
axis the concentration (1, 0.880, 0.746, 0.761)
and on the y
axis the different horizons (h1, h2, h3, h4)
. But I would like the y
axis to go downward (as in a soil profile), and the x
axis on the top of that plot.
我想在x轴上具有浓度(1,0.880,0.746,0.761)并且在y轴上具有不同的视野(h1,h2,h3,h4)。但我希望y轴向下(如在土壤剖面中),并且x轴在该图的顶部。
Here's what I've got so far: (I have tried many other things but without success)
这是我到目前为止所得到的:(我尝试过很多其他的东西,但没有成功)
test=factor(names(a))
plot(a,test)
axis(3)
This shouldn't be so hard but even after checking ?axis
, ?plot
and ?par
, I can't manage to get what I want.
这应该不是那么难,但即使在检查?轴,?情节和?标准之后,我也无法得到我想要的东西。
1 个解决方案
#1
1
Instead of that, you may want to customize your plot:
而不是那样,你可能想要自定义你的情节:
require(ggplot2)
a <- data.frame(horizon = c("h1", "h2", "h3", "h4"), vals = c(1.000, 0.880, 0.746, 0.761))
ggplot(a, aes(x = vals, y = horizon)) +
geom_point() +
scale_y_discrete(limits = rev(levels(a$horizon)))+
scale_x_continuous(position = "top")
The ggplot2
package is far easier to customize.
ggplot2包更容易定制。
#1
1
Instead of that, you may want to customize your plot:
而不是那样,你可能想要自定义你的情节:
require(ggplot2)
a <- data.frame(horizon = c("h1", "h2", "h3", "h4"), vals = c(1.000, 0.880, 0.746, 0.761))
ggplot(a, aes(x = vals, y = horizon)) +
geom_point() +
scale_y_discrete(limits = rev(levels(a$horizon)))+
scale_x_continuous(position = "top")
The ggplot2
package is far easier to customize.
ggplot2包更容易定制。