4

I am experiencing difficulties to plot a curve using pgfplots. I am unable to remove the empty space under the x-axis.

Here is my code:

\documentclass[11 pt]{article}
\pagestyle{empty}
\usepackage{tikz, pgfplots}

\begin{document}
    
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
axis y line = center,
axis x line = center,
xlabel = $x$,
ylabel = {$f(x)$},
thick,
xticklabels=\empty,
yticklabels=\empty,
xmin=-5.5,
xmax=5.5,
ymin=0,
ymax=3,
axis equal, 
grid,
]
\addplot [
domain=-5.5:5.5, 
samples=100, 
color=colour3,
thick,
smooth,
]
{0.33*sin(10*deg(x))*x + 0.66*abs(x)};
\end{axis}
\end{tikzpicture}
        
\end{figure}

\end{document}

Here is the output

output

There is a lot of unused space under the x-axis despite that I used \ymin=0. What did I do wrong?

3
  • 2
    I have no experience whatsoever with pgfplots but I'd guess the the option axis equal is interfering with ymin.
    – campa
    Dec 2, 2020 at 14:36
  • remove axis=equal - - tex.stackexchange.com/a/298757/197451
    – js bibra
    Dec 2, 2020 at 14:36
  • You are asking for axis equal --- and the standard width/height ratio of the plot is something similar to 4:3 (if I remember well); the two things are incompatible. So either you renounce to axis equal or tweak the width and height of the graph.
    – Rmano
    Dec 2, 2020 at 14:37

1 Answer 1

2

enter image description here

\documentclass[11 pt]{article}
\pagestyle{empty}
\usepackage{tikz, pgfplots}

\begin{document}
    
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
axis y line = center,
axis x line = center,
xlabel = $x$,
ylabel = {$f(x)$},
thick,
xticklabels=\empty,
yticklabels=\empty,
xmin=-5.5,
xmax=5.5,
ymin=0,
ymax=6,
%axis equal, 
grid,
]
\addplot [
domain=-5.5:5.5, 
samples=100, 
%color=colour3,
thick,
smooth,
]
{0.33*sin(10*deg(x))*x + 0.66*abs(x)};
\end{axis}
\end{tikzpicture}
        
\end{figure}

\end{document}
1
  • 1
    Indeed.. Thanks!
    – Andros
    Dec 2, 2020 at 14:37

You must log in to answer this question.

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