Graphics, Figures & TablesSub-graph

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Sub-graph

Post by layuval »

Hello everyone!

I would happy to get some help since its quite urgent.
I'm trying to have two graphs one next to each other (preferably sub graph). The only time I was close was when they were not in the same level and one was out of the margins.

I'm attaching the two graphs, will appreciate any help.

Code: Select all

\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{amsmath,multirow,booktabs, caption, boldline, cellspace,array,multirow,tikz,scrextend,float,pgfplots,amssymb,setspace,apacite,amsthm,inputenc,}
\usepackage[format=hang,font=small,labelfont=bf]{caption}
\usepackage[T1]{fontenc}
\usepackage{mwe}    % loads »blindtext« and »graphicx«
\usepackage{subfig}
%preamble:
\onehalfspacing
\makeatletter
\newenvironment{tikzlegend}[1][]{%
  \begingroup
    \csname pgfplots@init@cleared@structures\endcsname
    \pgfplotsset{#1}}{\csname pgfplots@createlegend\endcsname
  \endgroup
}
\def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
\makeatother
\author{}
\title{}
\begin{document}
%content:
\maketitle %prints preamble material onto pdf







\begin{figure}[H]

 \centering

\begin{tikzpicture}

\tikzstyle{every node}=[font=\huge]

\end{tikzpicture}
\begin{tikzpicture}

 \draw[semithick,->] (0,0) -- (7.6,0) node[right] {$ \alpha $};
 \draw[semithick,->] (0,0) -- (0,6) node[above]  {$ SW^{ea}, SW^{ed} $};   
\path[thick,cyan,draw]   (0,5.4) node[right]{} .. controls (1,3) .. (2.8,2.5);
\path[thick,densely dotted,draw]   (2.8,5.4) node[right]{} .. controls (3.8,2.1) .. (5.6,2);
\path[thin,densely dashdotted,draw,purple]   (0,2) node[left]{\small$SW^{monopoly}$} .. controls (4,2) .. (7.2,2);
\path[thin,dashed,draw]   (2.3,4.4) node[left]{\small$SW^{ea}(\alpha) $} .. controls (2.3,4.4) .. (2.3,4.4);     
\path[thin,dashed,draw]   (5.6,4.4) node[left]{\small$ SW^{ed}(\alpha, \hat f_t, c_t$)} .. controls (5.6,4.4) .. (5.6,4.4); 
\path[thick,loosely dotted,draw]   (0,5.4) node[below]{\small} .. controls (0,5.4) .. (5.6,5.4);    
\path[thick,dashed,draw]   (5.6,0) node[below]{\small$\alpha_{max}$} .. controls (5.6,2) .. (5.6,5.6);
\path[thick,dashed,draw]   (2.8,0) node[below]{\small$\hat\alpha_t$} .. controls (2.8,2) .. (2.8,5.6);
\path[thin,loosely dashdotted,draw]   (0,5.4) node[left]{\small$\frac{15a^2}{32}$} .. controls (0,5.4) .. (0,5.4);
\end{tikzpicture}
\caption{\bf{Diagrammatic representation of Lemma 3}}
\end{figure}



\begin{figure}[H]

 \centering
\begin{tikzpicture}
\tikzstyle{every node}=[font=\huge]

\end{tikzpicture}
\begin{tikzpicture}

    \draw[semithick,->] (0,0) -- (7.6,0) node[right] {$ f$};
    \draw[semithick,->] (0,0) -- (0,6) node[above]  {$ SW^{ea}, SW^{ed} $};   

\path[thick,cyan,draw]   (0.5,0.5) node[right]{} .. controls (3,4) .. (6.4,4.7)node[right]{$SW^{ed}(\hat\alpha, f, c_l)$};
\path[thick,dotted,draw]   (2,0.5) node[right]{} .. controls (3.5,3) .. (6.4,3.8)node[right]{$SW^{ed}(\hat\alpha, f, c_h)$};
\path[thin,densely dashdotted,draw,purple]   (0,2) node[left]{$\frac{15a^2}{32}$} .. controls (4,2) .. (7.2,2)node[right]{\small$SW^{ea}(\alpha=0)$};
\path[thick,dashed,draw]   (3,0) node[below]{$\hat f_h$} .. controls (3,2) .. (3,2);
\path[thick,dashed,draw]   (1.6,0) node[below]{$\hat f_l$} .. controls (1.6,2) .. (1.6,2);

\end{tikzpicture}
\caption{\bf{Diagrammatic representation of Lemma 3}}
\end{figure}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Sub-graph

Post by Johannes_B »

You cannot put an elephant in a suitcase. It just won't fit.

I can provide a solution that simply scales down the image.

Code: Select all

\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{amsmath,multirow,booktabs, caption, boldline, cellspace,array,multirow,tikz,scrextend,float,pgfplots,amssymb,setspace,apacite,amsthm,inputenc,}
\usepackage[format=hang,font={small,bf},labelfont=bf]{caption}
\usepackage{subcaption}
\usepackage[T1]{fontenc}
\usepackage{mwe}    % loads »blindtext« and »graphicx«
%\usepackage{subfig}% JB subcaption is much better
\usepackage{showframe}
%preamble:
\onehalfspacing
\makeatletter
\newenvironment{tikzlegend}[1][]{%
	\begingroup
	\csname pgfplots@init@cleared@structures\endcsname
	\pgfplotsset{#1}}{\csname pgfplots@createlegend\endcsname
	\endgroup
}
\def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
\makeatother
\author{}
\title{}
\begin{document}
%content:
\maketitle %prints preamble material onto pdf







\begin{figure}

	\begin{subfigure}{.5\linewidth}
		\centering
		\resizebox{\linewidth}{!}{%
		\begin{tikzpicture}
		\draw[semithick,->] (0,0) -- (7.6,0) node[right] {$ \alpha $};
		\draw[semithick,->] (0,0) -- (0,6) node[above]  {$ SW^{ea}, SW^{ed} $};  
		\path[thick,cyan,draw]   (0,5.4) node[right]{} .. controls (1,3) .. (2.8,2.5);
		\path[thick,densely dotted,draw]   (2.8,5.4) node[right]{} .. controls (3.8,2.1) .. (5.6,2);
		\path[thin,densely dashdotted,draw,purple]   (0,2) node[left]{\small$SW^\text{monopoly}$} .. controls (4,2) .. (7.2,2);
		\path[thin,dashed,draw]   (2.3,4.4) node[left]{\small$SW^{ea}(\alpha) $} .. controls (2.3,4.4) .. (2.3,4.4);    
		\path[thin,dashed,draw]   (5.6,4.4) node[left]{\small$ SW^{ed}(\alpha, \hat f_t, c_t$)} .. controls (5.6,4.4) .. (5.6,4.4);
		\path[thick,loosely dotted,draw]   (0,5.4) node[below]{\small} .. controls (0,5.4) .. (5.6,5.4);    
		\path[thick,dashed,draw]   (5.6,0) node[below]{\small$\alpha_\text{max}$} .. controls (5.6,2) .. (5.6,5.6);
		\path[thick,dashed,draw]   (2.8,0) node[below]{\small$\hat\alpha_t$} .. controls (2.8,2) .. (2.8,5.6);
		\path[thin,loosely dashdotted,draw]   (0,5.4) node[left]{\small$\frac{15a^2}{32}$} .. controls (0,5.4) .. (0,5.4);
	\end{tikzpicture}}
	\caption{}

	\end{subfigure}\hfill
	\begin{subfigure}{.5\linewidth}



		\resizebox{\linewidth}{!}{%
	\begin{tikzpicture}

		\draw[semithick,->] (0,0) -- (7.6,0) node[right] {$ f$};
		\draw[semithick,->] (0,0) -- (0,6) node[above]  {$ SW^{ea}, SW^{ed} $};  

		\path[thick,cyan,draw]   (0.5,0.5) node[right]{} .. controls (3,4) .. (6.4,4.7)node[right]{$SW^{ed}(\hat\alpha, f, c_l)$};
		\path[thick,dotted,draw]   (2,0.5) node[right]{} .. controls (3.5,3) .. (6.4,3.8)node[right]{$SW^{ed}(\hat\alpha, f, c_h)$};
		\path[thin,densely dashdotted,draw,purple]   (0,2) node[left]{$\frac{15a^2}{32}$} .. controls (4,2) .. (7.2,2)node[right]{\small$SW^{ea}(\alpha=0)$};
		\path[thick,dashed,draw]   (3,0) node[below]{$\hat f_h$} .. controls (3,2) .. (3,2);
		\path[thick,dashed,draw]   (1.6,0) node[below]{$\hat f_l$} .. controls (1.6,2) .. (1.6,2);

	\end{tikzpicture}}
	\caption{}
	\end{subfigure}
	\caption{Diagrammatic representation of Lemma 3}
\end{figure}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Re: Sub-graph

Post by layuval »

Thanks a lot!!!
Post Reply