2

This could be a silly question, but how would you modify the codes below to show the origin $O$ without change the xmin and ymin values?

The following is the resulting graph from the code.

graph

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\textbf{Question 3} (10 marks)\\[0.124cm]
\begin{center}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
axis lines=middle,
grid=major,
minor tick num=4,
grid=both,
grid style={line width=.1pt, draw=gray!30},
major grid style={line width=.2pt,draw=gray!50},
xmin=0,
xmax=61,
ymin=0,
ymax=122,
height=14cm,
width=15cm,
xlabel=$\textit{Time (minutes)}$,
ylabel=$\textit{Cumulative Frequency}$,
xtick={0,5,10,15,20,25,30,35,40,45,50,55,60},
%symbolic x coords={0,5,10,15,20,25,30,35,40,45,50,55,60},
ytick={0,10,20,30,40,50,60,70,80,90,100,110,120},
%ylabel=\textit{distance}\text{ (cm)},
ylabel style={
anchor=south,
at={(ticklabel* cs:1.0)},
yshift=5pt
},
xlabel style={
anchor=west,
at={(ticklabel* cs:1.0)},
xshift=5pt
},
%xlabel=\textit{t}\text{ (s)},
%yticklabel style={
%fill=white,
%yshift=10pt,
%},
%xticklabel style={
%xshift=10pt,
%fill=white
%},
]
\draw [thick] (axis cs:5,0) edge[bend right=30] (axis cs:40,60);
\draw [thick] (axis cs:40,60) edge[bend left=10] (axis cs:60,120);
%
\node [below] at (axis cs:-1,0) {$O$};
\end{axis}
\newline
\end{tikzpicture}
\end{center}
\end{document}
Sebastiano
  • 54,118
Will Kim
  • 2,032

1 Answers1

3

You can just a node. (You only need to make sure you do not clip it away.)

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{amsmath}
\setlength\parskip{0pt}
\begin{document}
\textbf{Question 3} (10 marks)\\[0.124cm]
\begin{center}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
axis lines=middle,
grid=major,
minor tick num=4,
grid=both,
grid style={line width=.1pt, draw=gray!30},
major grid style={line width=.2pt,draw=gray!50},
xmin=0,
xmax=61,
ymin=0,
ymax=122,
height=14cm,
width=15cm,
xlabel=$\textit{Time (minutes)}$,
ylabel=$\textit{Cumulative Frequency}$,
xtick={0,5,10,15,20,25,30,35,40,45,50,55,60},
%symbolic x coords={0,5,10,15,20,25,30,35,40,45,50,55,60},
ytick={0,10,20,30,40,50,60,70,80,90,100,110,120},
clip=false
%ylabel=\textit{distance}\text{ (cm)},
% ylabel style={
% anchor=south,
% at={(ticklabel* cs:1.0)},
% yshift=5pt
% },
% xlabel style={
% anchor=west,
% at={(ticklabel* cs:1.0)},
% xshift=5pt
% },
%xlabel=\textit{t}\text{ (s)},
%yticklabel style={
%fill=white,
%yshift=10pt,
%},
%xticklabel style={
%xshift=10pt,
%fill=white
%},
]
\draw [thick] (axis cs:5,0) edge[bend right=30] (axis cs:40,60);
\draw [thick] (axis cs:40,60) edge[bend left=10] (axis cs:60,120);
%
\node [anchor=north] at (axis cs:0,0) {$O$};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

If you do not want to remove the clip, you could just do

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{amsmath}
\setlength\parskip{0pt}
\begin{document}
\textbf{Question 3} (10 marks)\\[0.124cm]
\begin{center}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
axis lines=middle,
grid=major,
minor tick num=4,
grid=both,
grid style={line width=.1pt, draw=gray!30},
major grid style={line width=.2pt,draw=gray!50},
xmin=0,
xmax=61,
ymin=0,
ymax=122,
height=14cm,
width=15cm,
xlabel=$\textit{Time (minutes)}$,
ylabel=$\textit{Cumulative Frequency}$,
xtick={0,5,10,15,20,25,30,35,40,45,50,55,60},
%symbolic x coords={0,5,10,15,20,25,30,35,40,45,50,55,60},
ytick={0,10,20,30,40,50,60,70,80,90,100,110,120},
%ylabel=\textit{distance}\text{ (cm)},
% ylabel style={
% anchor=south,
% at={(ticklabel* cs:1.0)},
% yshift=5pt
% },
% xlabel style={
% anchor=west,
% at={(ticklabel* cs:1.0)},
% xshift=5pt
% },
%xlabel=\textit{t}\text{ (s)},
%yticklabel style={
%fill=white,
%yshift=10pt,
%},
%xticklabel style={
%xshift=10pt,
%fill=white
%},
]
\draw [thick] (axis cs:5,0) edge[bend right=30] (axis cs:40,60);
\draw [thick] (axis cs:40,60) edge[bend left=10] (axis cs:60,120);
%
\end{axis}
\node [anchor=north] at (0,0) {$O$};
\end{tikzpicture}
\end{center}
\end{document}

Note, however, that this works here sort of by accident. You may also try to add a named coordinate \coordinate (O) at (axis cs:0,0); inside the axis environment and then draw the node outside with \node [anchor=north] at (O) {$O$};. However, I experience minor shifts when trying this out. Whether or not this has any relation to what is discussed here, I do not know.