Overleaf グラフ設計の質問

Overleaf グラフ設計の質問

したい

  1. 右上隅に凡例を配置します。
  2. 5単位ごとに背景のグリッド線を追加します。
  3. 画像のサイズを修正します(このグラフの値 30 が別のグラフの値 30 と同じ長さになるように、異なるデータを同じ形式で配置します)。
  4. Overleaf から png ファイルでファイルをダウンロードする方法があるかどうか知りたいです。

よろしくお願いします。

\pgfplotstableread[row sep=\\,col sep=&]{
    type & before & after   \\
    ICE         & 25.9  & 20.9  \\
    HEV         & 18.9 & 15.9   \\
    PHEV        & 13.2 & 14.3   \\
    BEV         & 23.6 & 26.4  \\
    FCEV        & 18.5  & 22.5  \\
    }\groupaideal 
    
\begin{tikzpicture}
    \begin{axis}[
            title = Ideal fleet composition (Group A),
            ybar,
            bar width=.75cm,
            width=\textwidth*1.1,
            height=.5\textwidth,
            legend pos = outer north east, 
            legend style = {draw=none, column sep=2mm},
           legend columns = 1, 
            legend style={at={(1,0.5)},
            anchor=north,legend columns=-1},
            hide y axis, 
            axis x line*=bottom,
            symbolic x coords={ICE, HEV, PHEV, BEV, FCEV},
            xtick=data,
%            xticklabel style = {align=center, text width=3mm},
            nodes near coords={\pgfmathprintnumber[fixed, precision=1]\pgfplotspointmeta},
            nodes near coords align={vertical},
            every node near coord/.append style = {display text={\pgfmathprintnumber[fixed,precision=1]\pgfplotspointmeta}},
            ymin=0,
%            ylabel={\%},
        ]
       \addplot[fill=white, draw=black]table[x=type,y=before]{\groupaideal};
       \addplot[fill=gray, draw=black]table[x=type,y=after]{\groupaideal};
       \legend{Baseline, Informed}
    \end{axis}

\end{tikzpicture}

答え1

このような ?

ここに画像の説明を入力してください

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}

\pgfplotstableread[row sep=\\,col sep=&]{
    type & before & after   \\
    ICE         & 25.9  & 20.9  \\
    HEV         & 18.9 & 15.9   \\
    PHEV        & 13.2 & 14.3   \\
    BEV         & 23.6 & 26.4  \\
    FCEV        & 18.5  & 22.5  \\
    }\groupaideal 

\begin{tikzpicture}
    \begin{axis}[
            title = Ideal fleet composition (Group A),
            ybar,
            bar width=.75cm,
            width=\textwidth,
            height=.5\textwidth,
            legend pos=outer north east,
            legend style={at={(1.05,1)},anchor=north west}, % top-right corner outside
            axis y line*=left, % Y axis line
            axis x line*=bottom,
            ymajorgrids=true, % major gridlines
            grid style=dashed,
            symbolic x coords={ICE, HEV, PHEV, BEV, FCEV},
            xtick=data,
            ymin=0, ymax=35, % max to make plots consistent
            ytick={0,5,...,35}, % every 5 units
            nodes near coords,
            nodes near coords align={vertical},
        ]
       \addplot[fill=white, draw=black]table[x=type,y=before]{\groupaideal};
       \addplot[fill=gray, draw=black]table[x=type,y=after]{\groupaideal};
       \legend{Baseline, Informed}
    \end{axis}
\end{tikzpicture}

\end{document}

このサイトには、あなたが求めているオプションの例がたくさんあります...

関連情報