5

Well, simply, my code gives the graph below. What I have.

But what I want is something like Fig. 30 (p. 56, Advanced Engineering Mathematics, 9th Ed. by Irvine Kreszig).

What I want

\ssfamily font for the tick label, axis label position and a bit more space for it.

Preamble:

\usepackage{xcolor}
\usepackage{pgfplots}
    \pgfplotsset{compat=newest}
    \pgfplotsset{small, every non boxed x axis/.append style={x axis line style=-},
every non boxed y axis/.append style={y axis line style=-}}

My code:

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
        axis lines= middle,
        ylabel=$y$,
        xlabel=$t$,
        height=100pt,
        ymax=3, ymin=-1,
        minor y tick num=1,
        minor x tick num=1,     
        restrict y to domain=-20:20,
]

\addplot[
    thick,
    orange,
    domain=0:15,
    samples=100,
%   fill=orange!60!white,
]
{(3-2*x)*exp(-0.5*x)};
\end{axis}
\end{tikzpicture}
\caption{The sample function, $y=(3-2x)e^{-0.5x}$.}
\end{figure}

Sorry, if it's long a bit.

  • On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – Benedikt Bauer Mar 31 '14 at 11:09
  • Can you give your code? – percusse Mar 31 '14 at 11:10
7

This is one attempt where the second set of pgfplotsset{....} is to set the font family and the following two commands is to rename the \figurename and numbering.

\renewcommand\figurename{Fig.}
\setcounter{figure}{29}

and x and y label position are allocated to location at (x,y) via

ylabel=$y$, y label style={at={(0.05,1)}},
xlabel=$t$, x label style={at={(1,0.3)}},

enter image description here

Code

\documentclass[]{article}

\usepackage{xcolor}
\usepackage{pgfplots}
\usepackage[eulergreek]{sansmath}        %%% newly added for font family
\pgfplotsset{
compat=newest, 
small, every non boxed x axis/.append style={x axis line style=-},
every non boxed y axis/.append style={y axis line style=-}
}

\pgfplotsset{                            %%% newly added for font family setting
  tick label style = {font=\sansmath\sffamily},
  every axis label = {font=\sansmath\sffamily},
%  legend style = {font=\sansmath\sfamily},
  label style = {font=\sansmath\sffamily}
}

\renewcommand\figurename{Fig.}
\setcounter{figure}{29}

\begin{document}
\begin{figure}
\begin{tikzpicture}%[inner sep=0.2cm]

\begin{axis}[
        axis lines= middle,
        ylabel=$y$, y label style={at={(0.05,1)}},  %%% newly added
        xlabel=$t$, x label style={at={(1,0.3)}},   %%% newly added
%        height=100pt,
        ymax=3, ymin=-1,
        minor y tick num=1,
        minor x tick num=1,     
        restrict y to domain=-20:20,
        width=8cm, height=5cm,                      %%% newly added 
]

\addplot[
    thick,
    orange,
    domain=0:15,
    samples=100,
%   fill=orange!60!white,
]
{(3-2*x)*exp(-0.5*x)};
\end{axis}
\end{tikzpicture}
\caption{Solution in Example 4}
\end{figure}

\end{document}
| improve this answer | |
  • Thanks for help. It's good. However, the axis x label needs to be below the axis and for y to the left, like the figure. – Milad O. Mar 31 '14 at 16:02
  • 1
    @Milad -- OK, for axis x label uses (1,-0.05) and for axis y label uses (-0.12,1.2). Actually you could try (0,0) and (1,1) to see that the label will be located at lower left and upper right corners forming a rectangle. Use negative values for reverse directions. Thus you could put the label anywhere. – Jesse Mar 31 '14 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.