Graphics, Figures & TablesTikZ comments

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

TikZ comments

Post by layuval »

Hello everyone,
I have a problem with comments under graph.
I'm trying to write comments below my graph that indicates what each line means.
Something like:
------------- parents salary
..................... number of kids

The problem is that I can't get dashed-dotted and dotted lines.

Below are my commends.
Any help will be appreciated!

Code: Select all

Code, edit and compile here:
\node[inner sep=0pt,outer sep=0pt, font=\tiny,label={[yshift=-1.5ex]north west:{\scriptsize $Note:$}},text width=0.6\textwidth,anchor=north west] at ([yshift=-2,xshift=0.7cm]current bounding box.south west)
{\scriptsize \dashedrule monopolist profit within entry allowance.\\
\scriptsize \solidrule monopolist profit within entry deterrence.\\
\scriptsize \dottedrule monopolist profit within entry deterrence.\\
\scriptsize $\alpha^{max}<\alpha$ monopoly outcome};
\end{tikzpicture}
\end{figure}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

TikZ comments

Post by Stefan Kottwitz »

You can use \draw[dashed] or \draw[dotted] or \draw[densely dashed], and nodes, or the quotes library syntax. Perhaps show a complete drawing, otherwise we cannot test anything.

Stefan
LaTeX.org admin
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

TikZ comments

Post by layuval »

Sure, I have attached.
As can be seen I have tried to improvise but its not going well.

Code: Select all

Code, edit and compile here:
\documentclass[border=80pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzstyle{every node}=[font=\huge]
\end{tikzpicture}
\begin{tikzpicture}
\draw[semithick,->] (0,0) -- (3.5,0) node[right] {$ \alpha $};
\draw[semithick,->] (0,0) -- (0,2.5) node[above] {$ \pi_m $};
\path[thick,cyan,draw] (0,0) node[right]{} .. controls (2,2) .. (3.2,2);
\path[thick,dotted,draw] (0,0) node[right]{} .. controls (1.2,2) .. (2.8,2);
\path[thick,dashed,draw] (2.2,0) node[below]{\small$ \alpha{'}_{max}$} .. controls (2.2,0) .. (2.2,2);
\path[thick,dashed,draw] (0.631,0) node[below]{\small$\hat{ \alpha}{'}$} .. controls (0.631,1) .. (0.631,1);
\path[thick,dashdotted,draw,purple] (0,1) node[left]{\small$ \pi^{ea}$} .. controls (2,1) .. (3.2,1);
%\path[thin,dashed,draw] (0,2) node[left]{\small$ \pi^{m}$} .. controls (0,2) .. (2.7,2);
\path[thick,dashed,draw] (2.8,2) node[above]{} .. controls (2.8,0) .. (2.8,0);
\path[thick,dashed,draw] (3,0) node[below]{\small$ \alpha_{max}$} .. controls (3,0) .. (3,0);
\path[thick,dashed,draw] (1,0) node[below]{\small$\hat{\alpha}$} .. controls (1,1) .. (1,1);
%\path[thick,dashed,draw] (1.5,1.3) node[above]{\tiny$ \pi_{ed}$} .. controls (1.5,1.3) .. (1.5,1.3);
\node[inner sep=0pt,outer sep=0pt, font=\tiny,label={[yshift=-1.5ex]north west:{\scriptsize $Note:$}},text width=0.6\textwidth,anchor=north west] at ([yshift=-2,xshift=0.7cm]current bounding box.south west)
{\scriptsize $^{...}$ monopolist profit within entry allowance.\\
\scriptsize $^-$monopolist profit within entry deterrence.\\
\scriptsize $\alpha^{max}<\alpha$ monopoly outcome};
\end{tikzpicture}
\end{document}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Last edited by Stefan Kottwitz on Sun Aug 28, 2016 2:02 pm, edited 2 times in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

TikZ comments

Post by Stefan Kottwitz »

I would use pgfplots for the whole image. Though the pgfplots author Christian Feuersänger provided a way to use a pgfplots legend in a TikZ picture.

Here is how we could do it:

Code: Select all

Code, edit and compile here:
\usepackage{pgfplots}
\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
%...
% at the end of the picture:
\begin{tikzlegend}[legend entries={monopolist profit within entry allowance,
monopolist profit within entry deterrence,something else},
legend style={at={(0,-1)},anchor=north west}, legend cell align=left]
\addlegendimage{dotted,sharp plot}
\addlegendimage{sharp plot}
\addlegendimage{dashed, sharp plot}
\end{tikzlegend}
\end{tikzpicture}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Whole code:

Code: Select all

Code, edit and compile here:
\documentclass[border=80pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\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
\begin{document}
\begin{tikzpicture}
\draw[semithick,->] (0,0) -- (3.5,0) node[right] {$ \alpha $};
\draw[semithick,->] (0,0) -- (0,2.5) node[above] {$ \pi_m $};
\path[thick,cyan,draw] (0,0) node[right]{} .. controls (2,2) .. (3.2,2);
\path[thick,dotted,draw] (0,0) node[right]{} .. controls (1.2,2) .. (2.8,2);
\path[thick,dashed,draw] (2.2,0) node[below]{\small$ \alpha{'}_{\max}$}
.. controls (2.2,0) .. (2.2,2);
\path[thick,dashed,draw] (0.631,0) node[below]{\small$\hat{ \alpha}{'}$}
.. controls (0.631,1) .. (0.631,1);
\path[thick,dashdotted,draw,purple] (0,1) node[left]{\small$ \pi^{ea}$}
.. controls (2,1) .. (3.2,1);
\path[thick,dashed,draw] (2.8,2) node[above]{}
.. controls (2.8,0) .. (2.8,0);
\path[thick,dashed,draw] (3,0) node[below]{\small$ \alpha_{\max}$}
.. controls (3,0) .. (3,0);
\path[thick,dashed,draw] (1,0) node[below]{\small$\hat{\alpha}$}
.. controls (1,1) .. (1,1);
\begin{tikzlegend}[legend entries={monopolist profit within entry allowance,
monopolist profit within entry deterrence,something else},
legend style={at={(0,-1)},anchor=north west}, legend cell align=left]
\addlegendimage{dotted,sharp plot}
\addlegendimage{sharp plot}
\addlegendimage{dashed, sharp plot}
\end{tikzlegend}
\end{tikzpicture}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
plot.png
plot.png (10.87 KiB) Viewed 7541 times
Btw. I would use \max for an upright max.

Stefan
LaTeX.org admin
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Re: Tikz comments

Post by layuval »

Thanks,
Is there a possibility to get the same result without the box being seen?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

TikZ comments

Post by Stefan Kottwitz »

Sure, insert draw=none here in the legend style:

Code: Select all

..., legend style={at={(0,-1)},anchor=north west,draw=none}, ...
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Stefan
LaTeX.org admin
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Re: Tikz comments

Post by layuval »

Thanks again.
It works fine when it runs by itself but not when I add it to my article.
Any suggestions why?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Tikz comments

Post by Stefan Kottwitz »

Only if you would post the error message, possibly the whole preamble of your article. Otherwise I cannot know what happens in that other document.

Stefan
LaTeX.org admin
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

TikZ comments

Post by layuval »

Obviously, thanks again!

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{amsmath,multirow,booktabs, caption, boldline, cellspace,array,multirow,tikz,scrextend,float,pgfplots,}
%preamble:
\author{Name
\\Supervisor:name}
\title{title}
\begin{document}
%content:
\maketitle %prints preamble material onto pdf
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

TikZ comments

Post by Stefan Kottwitz »

That preamble doesn't contain the definition of tikzlegend and \addlegendimage.

Stefan
LaTeX.org admin
Post Reply