4

How can I plot the following bar graph with a base value of -60 instead of 0(default)?

enter image description here

\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[baseline]
\centering
\begin{axis}[ybar,bar width=1,line width=2,
 ylabel=Output Power(dBm),
xlabel=Frequency(GHz),label style={font=\bfseries\LARGE},
legend style={legend pos= south east},
tick label style={font=\bfseries\Large},
grid=major,anchor=north]
\addplot coordinates
{(100,-24)(200,5.5)(300,-55)(400,-9.5)};
\end{axis}

\end{tikzpicture}
\end{document}

1 Answer 1

3

I don't know exactly what you mean by the base but here is one possibility to shift the relative value to -60

\documentclass[convert={density=400,outext=.png}]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[baseline]
\centering
\begin{axis}[
    ybar,
    bar width=1,
    line width=2,
    ylabel=Output Power(dBm),
    xlabel=Frequency(GHz),
    label style={font=\bfseries\LARGE},
    legend style={legend pos= south east},
    tick label style={font=\bfseries\Large},
    grid=major,
    anchor=north,
    y coord trafo/.code={\pgfmathparse{#1+60}},    % Addition
    y coord inv trafo/.code={\pgfmathparse{#1-60}} % Addition
    ]
\addplot coordinates{(100,-24)(200,5.5)(300,-55)(400,-9.5)};
\end{axis}

\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .