如何在R的图表右侧添加轴 - 进一步开发Pareto Chart

时间:2016-10-24 18:26:46

标签: r plot ggplot2 axis

帕累托图继续在发展中。

效果被Half_Effect取代,应标记为| Half Effect |在y轴上。怎么做。我一直都有错误。

带有累积百分比线的

pareto.chart不行。我需要将其与图表右侧的轴进行协调。怎么办?

ChartData

EffectX用于识别x轴上的位置,它特定于此数据。我希望这是通用的

#  EffectX Frequency Cum.Freq Percentage Cum.Percent  
#1    0.65  10.43800 10.43800  39.295364    39.29536
#2    2.00   6.52080 16.95880  24.548497    63.84386
#3    3.20   5.64580 22.60460  21.254432    85.09829
#4    4.40   1.56250 24.16710   5.882258    90.98055
#5    5.50   0.97917 25.14627   3.686227    94.66678
#6    6.75   0.77083 25.91710   2.901901    97.56868
#7    8.05   0.64583 26.56293   2.431321   100.00000

EffectNames=c( "Pull Back(A)","Hook(B)", "Peg(C)","AB", "BC", "AC", "ABC")
Half_Effect=c( 10.4,6.5,5.6,1.6,0.98,.77,.65 )
paretoData=data.frame(EffectNames, Half_Effect)
paretoData
paretoData$EffectNames = factor(paretoData$EffectNames, 
    levels=c("Pull Back(A)","Hook(B)", "Peg(C)","AB", "BC", "AC", "ABC"))
p=ggplot(paretoData, aes(x=EffectNames, y=Half_Effect)) +
geom_bar(stat="identity") +
geom_text(aes(label=Half_Effect), vjust=1.5, colour="white")+
geom_line(data=chartData,aes(x=EffectX,y=Cum.Percent))
p

真诚的,MM

0 个答案:

没有答案