Latex 如何在带有两个y轴标签的相邻条形图上旋转此pgf绘图

Latex 如何在带有两个y轴标签的相邻条形图上旋转此pgf绘图,latex,tex,tikz,pgf,Latex,Tex,Tikz,Pgf,我有以下代码,大致近似于我想用tikz制作的图表: \begin{tikzpicture} \begin{axis}[ % (normal text should not be set in math mode) xlabel=, ylabel=, % if you use `data' ticks will be set on every x coordinate that is % given by the *first* `\addplot' command xtick=data, xti

我有以下代码,大致近似于我想用tikz制作的图表:

\begin{tikzpicture}
\begin{axis}[
% (normal text should not be set in math mode)
xlabel=,
ylabel=,
% if you use `data' ticks will be set on every x coordinate that is
% given by the *first* `\addplot' command
xtick=data,
xticklabels={
    Control,
    Voucher,
    Transfer%
},
ytick=data,
yticklabels={
    No increase,
    Increase%
},
% use the following key so the baseline of all ticklabel entries is the same
% (compare this image to the one from marmot)
typeset ticklabels with strut,
% there is one default value for the `legend pos' that is outside the axis
legend pos=outer north east,
% (so the legend looks a bit better)
legend cell align=left,
% (moved this common key here),
]
% (renamed `plot coordinates' by `coordinates'
\addplot [mark=*,blue] coordinates {
    (1,1)
    (2,1)
    (3,1)
};

\addplot [color=red,mark=x] coordinates {
    (1,1)
    (2,1)
    (3,2)
};

\addplot [color=green,mark=x] coordinates {
    (1,1)
    (2,2)
    (3,2)
};

% (replaced `\addlegendentry's with `\legend')
\legend{
    Pure Altruism,
    Warm Glow,
    Mental Accounting,
}
\end{axis}
\end{tikzpicture}

正如您所看到的,我试图添加y轴记号标签,但实际的图表本身并没有出现这种情况。此外,我试图说明的是本质上是离散的,因此我希望x轴上的每个刻度都有三个相邻的条,这将说明在图例中的每个理论下,水平是“高”还是“低”

如何将其转换为具有三个相邻条形的条形图,并添加所需的两个y轴标签?

根据,当您使用
ytick=data
时,标签将从使用的第一个
\addplot
命令中提取。您的第一个
\addplot
命令仅包含
1
作为y记号标签

您可以显式定义标签:

ytick={1, 2},
或者更改
\addplot
命令的顺序,使其首先具有更具代表性的命令(同时具有所有x记号标签和所有y记号标签的命令)

根据,当您使用
ytick=data
时,将从使用的第一个
\addplot
命令中提取标签。您的第一个
\addplot
命令仅包含
1
作为y记号标签

您可以显式定义标签:

ytick={1, 2},
或者更改
\addplot
命令的顺序,使其首先具有更具代表性的命令(同时具有所有x记号标签和所有y记号标签的命令)