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}

이 사이트에는 귀하가 요청하는 옵션에 대한 많은 예가 있습니다...

관련 정보