Graphics, Figures & Tables ⇒ Comparison plot diagram
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Comparison plot diagram
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Comparison plot diagram
Stefan
Comparison plot diagram

Here's a not so minimal example that is fully working. I need to know if the code could be optimized in some way. I think it's slow to compile, for what it's doing.
Also, since the document is in French, there's a mistake somewhere I cannot isolate, and I had to fix it using a renew command to add space before the ":" for tables and figures. I think this is an hack. It should be done properly in another way :
Code: Select all
\renewcommand{\thetable}{\arabic{table}\,} % <--- this is probably an hack
\renewcommand{\thefigure}{\arabic{figure}\,} % <--- this is probably an hack. See code below
Code: Select all
\documentclass[10pt,twoside,nofootinbib]{revtex4}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{microtype}
\usepackage{moreverb}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,every tick/.style={black}}
\usepackage[separate-uncertainty=true]{siunitx}
\sisetup{output-decimal-marker = {,}}
\usepackage{icomma}
\usepackage{graphicx}
\usepackage{here}
\usepackage{subfig}
\captionsetup{figurename=Figure,margin=1cm,format=hang,font=small,format=plain,labelfont={bf,up},textfont={it}}
\captionsetup[subfigure]{margin=0cm,font=small,format=plain,labelfont={bf,up},textfont={up}}
\captionsetup[table]{name=Tableau,labelfont={bf,up}}
\renewcommand{\thetable}{\arabic{table}\,}
\renewcommand{\thefigure}{\arabic{figure}\,}
\usepackage[unicode,colorlinks,linkcolor=red,urlcolor=red,citecolor=red,pdftitle={Protocole de laboratoire du cours NYA},pdfauthor={Martin Charest},pdfproducer={pdfLaTeX},plainpages=false,hyperindex=true,pdfpagelabels]{hyperref}
\pagestyle{plain}
\raggedbottom
\newcommand*\pct{\protect\scalebox{0.9}{\%}}
\begin{document}
\begin{center}
\begin{minipage}{0.8\linewidth}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{l|c|c|c|c|c|}
\cline{2-6}
& \multicolumn{5}{c|}{A simple title} \\ \cline{2-6}
& \multicolumn{1}{>{\centering}p{6em}|}{$d$}
& \multicolumn{1}{>{\centering}p{6em}|}{$\Delta d$}
& \multicolumn{1}{>{\centering}p{6em}|}{$\ell$}
& \multicolumn{1}{>{\centering}p{6em}|}{$\Delta\ell$}
& \multicolumn{1}{>{\centering}p{6em}|}{$m$}
\\ \cline{2-6}
& \multicolumn{2}{c|}{\si{\mm}}
& \multicolumn{2}{c|}{\si{\km}}
& \si{\g}
\\ \cline{2-6}
& \multicolumn{2}{c|}{–}
& \multicolumn{2}{c|}{–}
& 0,1
\\ \hhline{b-|==|==|=|}
\multicolumn{1}{|l|}{Instrument 1} & 15 & 1 & 22 & 1 & \multirow{3}{*}{49,3} \\ \cline{1-5}
\multicolumn{1}{|l|}{Instrument 2} & 15,4 & 0,1 & 22,6 & 0,1 & \\ \cline{1-5}
\multicolumn{1}{|l|}{Instrument 3} & 15,42 & 0,03 & 22,57 & 0,02 & \\ \hline
\end{tabular} \\[10pt]
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|l|}
\hline
\multicolumn{1}{|c|}{Legend} \\ \hline
\, $d$ is this. \\
\, $\ell$ is that. \\
\, $m$ is too. \, \\ \hline
\end{tabular}
\end{minipage}
\end{center}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\pgfplotsset{major grid style={black,dotted}} % color=black works too
\begin{axis}[
scale only axis=true,
width=10cm,
height=2.5cm,
xlabel=$\rho \, (\si{\g/\cm^3})$,
ytick=\empty,
title={Comparison of this and that},
xmin=7.2,
xmax=8.0,
ymin=-1,
ymax=3,
xmajorgrids=true,
minor tick num=1,
%xtick align=center,
legend style={at={(1.26, 0.5)},anchor=center,font=\footnotesize,draw=none},
]
\addplot+[color=black,mark options={mark=*,mark size=2pt,fill=cyan,scale=1},error bars,x dir=both,x explicit]
coordinates {
(7.5, 2) +- (0.2, 0)
};
\addlegendentry{$A = \SI{7,5 +- 0,2}{\g/\cm^3}\hphantom{00}$};
\addplot+[color=black,mark options={mark=square*,mark size=2pt,fill=magenta,scale=1},error bars,x dir=both,x explicit]
coordinates {
(7.45, 1) +- (0.09, 0)
};
\addlegendentry{$B = \SI{7,45 +- 0,09}{\g/\cm^3}$};
\addplot+[color=black,mark options={mark=triangle*,mark size=2pt,fill=green,scale=1.3},error bars,x dir=both,x explicit]
coordinates {
(7.82, 0) +- (0.04, 0)
};
\addlegendentry{$C = \SI{7,82 +- 0,04}{\g/\cm^3}$};
\end{axis}
\end{tikzpicture}
\caption{A comparison diagram with a pourcentage $5\pct$.}
\end{figure}
Some pourcentages :
\begin{align*}
\delta A &= 3,0\pct,
&\delta B &= 3,6\pct,
&\delta C &= 1,2\pct.
\end{align*}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\pgfplotsset{major grid style={black,dotted}}
\begin{axis}[
scale only axis=true,
width=10cm,
height=2.5cm,
grid=none,
minor tick num=1,
%xtick align=center,
xlabel=$\rho \, (\si{\g/\cm^3})$,
ytick=\empty,
title={Comparaison des densités de masse volumique},
xmin=7.3,
xmax=7.9,
ymin=-1,
ymax=3,
axis x line = bottom,
axis y line = none,
legend style={at={(0.95, 0.5)},anchor=west,font=\footnotesize,draw=black},
]
\addplot+[color=black,mark options={mark=*,mark size=2pt,fill=gray,scale=1},error bars,x dir=both,x explicit]
coordinates {
(7.6, 2) +- (0.2, 0)
};
\addlegendentry{$A = \SI{7,6 +- 0,2}{\g/\cm^3}\hphantom{00}$};
\addplot+[color=black,mark options={mark=square*,mark size=2pt,fill=gray,scale=1},error bars,x dir=both,x explicit]
coordinates {
(7.65, 1) +- (0.09, 0)
};
\addlegendentry{$B = \SI{7,65 +- 0,09}{\g/\cm^3}$};
\addplot+[color=black,mark options={mark=triangle*,mark size=2pt,fill=gray,scale=1.3},error bars,x dir=both,x explicit]
coordinates {
(7.76, 0) +- (0.04, 0)
};
\addlegendentry{$C = \SI{7,76 +- 0,04}{\g/\cm^3}$};
\end{axis}
\end{tikzpicture}
\caption{A title}
\end{figure}
\end{document}
\pgfplotsset{major grid style={black,dotted}}
wasn't working, while \pgfplotsset{major grid style={color=black,dotted}}
is working. Now both codes are working in my main document. I don't know why it was different yesterday.Lastly, the percent symbol is now working everywhere because of the
\protect
command. I want to be sure that this is the "proper" way of doing this. Without the \protect command, the code doesn't work inside the caption environment.I find this a bit strange since that percent code is working great (without the
\protect
) in another (large !) project of mine, which is MUCH more complex than the document I made these last days.- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Comparison plot diagram
Code: Select all
Package frenchb.ldf Warning: Figures' and tables' captions might look like
(frenchb.ldf) `Figure 1:' which is wrong in French.
(frenchb.ldf) Check your class or packages to change this;
(frenchb.ldf) reported on input line 12.
Code: Select all
Package caption Warning: Unused \captionsetup[subfigure] on input line 19.
See the caption package documentation for explanation.
Package caption Warning: Unused \captionsetup[table] on input line 20.
See the caption package documentation for explanation.
Comparison plot diagram
Well, my document isn't about publishing anything to the APS. I'm using the revtex4 because of its nice compact output. It fits well my needs.Johannes_B wrote: This is ok, the editors of REVTeX will change your submission anyway. The American Physical Society decides about the layout of their journals.
So how to fix that "huge" warning ?
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Comparison plot diagram
Comparison plot diagram
With the revtex4 class, should I conclude that there isn't any "right" way to make a French document, and that I have to "hack" it like what I've done ?
This is important, since I was using that class for a lot of small documents, that I want to take only a few pages of paper.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Comparison plot diagram
article
(or scrartcl
) and use package geometry to change margins. I don't know what revtex is doing exactly.Journal classes tend to be grown over years of small changes and are (in general) a clutter of bad coding, incompatible to many packages. But why should they care? The layout matches their requirements and nobody should modify, say, captions to be different. All changes will simply be reverted.
Unfortunately, that is a problem to many many many beginners, that are looking for a template (whatever that is) and instead of a nice design/layout they find a journal template which is like a booby-trapped box of chocolates. Looks nice, but as soon as you want to replace one piece, it blows up.
Would be good, if you have questions, to open a new thread for the different topics.