10

X 軸にテキスト ラベルが付いた棒グラフがあります。中にはラベルがかなり長いものもあり、見た目をすっきりさせたいと考えています。どうすればそれを達成できるかについてのアイデアはありますか?

library(sjPlot)
require(ggplot2)
require(ggthemes)
WAM_3_plot <- sjp.frq(WAM_Dec13_R2$WAM_3, title= c("WAM Item 3"),
    axisLabels.x=c("Disruptive behaviour can be contained and does not spread to other patients.  Generally, behaviour on the ward is positive and pro-therapeutic.", 
                   "1", "2","3","4",
                   "Disruptive behaviour by one patient tends to spread to other patients and is only contained with great difficulty. The general level of behaviour seems to be getting more counter-therapeutic."),
    barColor = c("palegreen4", "palegreen3", "palegreen2", "brown1", "brown2", "brown3"),
    upperYlim = 25,
    valueLabelSize = 5,
    axisLabelSize = 1.2,
    breakLabelsAt=14, returnPlot=TRUE) 
WAM_3_plot + theme(axis.text.x=element_text(hjust=0.5))
4

3 に答える 3

1

パラメータを変更しbreakLabelsAt、 を減らして TRUE にaxisLabelSize設定すると、同様の結果が得られます。flipCoordinatessjPlot-package に含まれている efc-sample データ セットを使用しました。

data(efc)
sjp.frq(efc$e42dep, title=c("WAM Item 3"),
    axisLabels.x=c("Disruptive behaviour can be contained and does not spread to other patients.  Generally, behaviour on the ward is positive and pro-therapeutic.", 
      "1", "2",
      "Disruptive behaviour by one patient tends to spread to other patients and is only contained with great difficulty. The general level of behaviour seems to be getting more counter-therapeutic."),
    valueLabelSize=5,
    axisLabelSize=.8,
    breakLabelsAt=50,
    flipCoordinates=T)

ここに画像の説明を入力

于 2014-04-10T12:55:49.170 に答える
1

軸ラベルを回転させると、次のように大いに役立ちます。

theme(axis.text.x  = element_text(angle=90, vjust=0.5))
于 2014-01-31T12:27:38.447 に答える