1

I'd like to realize this picture in LaTeX to show radiation of the dipole. I've already ask this question Radiation diagram. But, I need to have the caption for each diagram WITHOUT using \subcaption! (because in my code I need to use \subfigure for something else and we can't use at the same time \subcaption and \subfigure,...)

My code is the following (taken from marmot's answer) to the linked question:

    \documentclass[11pt,a4paper]{article}
    \usepackage{subcaption}
    \usepackage{floatrow}
    \usepackage{pgfplots}
    \pgfplotsset{width=8cm,compat=1.16}
    \usepgfplotslibrary{polar}
\begin{document}
    \begin{figure}[htb]
    \floatsetup{valign=c, heightadjust=all}
    \ffigbox{%
    \begin{subfloatrow}
    \ffigbox{\begin{tikzpicture}
    \begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
            \addplot3[domain=0:360,domain y=0:360,samples=31,
            point meta=sqrt(x^2+y^2),
            colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
        z buffer=sort]
           ({(sin(x+90)*sin(x+90))*cos(y)}, 
            {(sin(x+90)*sin(x+90))*sin(y)}, 
            {(sin(x+90)*sin(x+90))*sin(x)});
    \end{axis}
    \path(current bounding box.south west) rectangle (current bounding box.north
    east);
    \end{tikzpicture}}{\caption{Diagramme de rayonnement du dipôle.\label{fig:Diagramme de rayonnement du dipôle}}}
    \ffigbox{\begin{tikzpicture}
    \begin{polaraxis}[axis lines = none]
        \addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
    \end{polaraxis}
    \draw[-stealth] ([yshift=2cm]current axis.south) -- ([yshift=-2cm]current axis.north);
    \end{tikzpicture}}{\caption{Coupe verticale du diagramme de rayonnement.\label{fig:Coupe verticale du diagramme de rayonnement}}}
    \end{subfloatrow}}
    {\caption{Rayonnement du dipôle demi-onde.}\label{fig:Rayonnement du dipôle demi-onde}}
    \end{figure}
\end{document}
  • 6
    I guess that people are hesitating to help for two reasons. 1. There is no code. How on earth would anybody know which fragment they are to provide that does not clash with your code? 2. subfigure is often said to be deprecated. There may not be enough motivation to replace something that is not deprecated by something that is. (And I guess you might benefit from linking this code such that those who are willing to help have a starting point.) – user121799 Jan 6 at 21:56
  • I'm just looking for an other way to realize the picture in latex. A different code than the one in the other topic if it's possible. I really need it... – Aurélien Jan 7 at 8:07
  • @Aurélien Thatnks for adding an example. It looks like that is taken from a previous answer to another of your questions. Usually, in such a case it's best to state explicitly that where it's from: helps give credit and makes sure any issues (or queries) can be tracked back to a source. – Joseph Wright Jan 8 at 8:41
3

enter image description here

mwe for above image is:

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{tabularx}

\begin{document}

\begin{figure}[htb]
\begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
\includegraphics[width=\linewidth]{example-image-duck}
\caption{3D presentation of dipole radiation}
\label{fig:dipol-1}
    &
\includegraphics[width=\linewidth, height=3cm]{example-image-duck}
\caption{3D presentation of dipole radiation}
\label{fig:dipol-2}
\end{tabularx}
\end{figure}

or

\begin{figure}[htb]
\begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
\includegraphics[width=\linewidth,valign=c]{example-image-duck}
    &
\includegraphics[width=\linewidth, height=3cm,valign=c]{example-image-duck}\\
%
\caption{3D presentation of dipole radiation}
\label{fig:dipol-1}
    &
\caption{3D presentation of dipole radiation}
\label{fig:dipol-2}
\end{tabularx}
\end{figure}

\end{document}

in case that you like to include code of images, than with them replace \includegraphics ... and for their vertical align use option baseline ... for the tikzpicture. Since you not provide mwe, i can't show anything further.

addendum:

Following the edit to the question (which uses code from https://tex.stackexchange.com/a/467985), if i understood you correctly, you looking for the following:

enter image description here

it is generated with the following mwe:

\documentclass[11pt,a4paper]{article}
%\usepackage{floatrow}  % not used in this mwe
                        % however it is troublemaker. do you really need it?
\usepackage{caption}    % not used in this mwe
\usepackage{subcaption} % not used in this mwe
\usepackage{tabularx}   % <--- new

 \usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}

\begin{document}
    \begin{figure}[htb]
\begin{tabularx}{\linewidth}{*{2}{>{\centering\arraybackslash}X}}
% left image
    \begin{tikzpicture}
\begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
        \addplot3[domain=0:360,domain y=0:360,samples=31,
        point meta=sqrt(x^2+y^2),
        colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
    z buffer=sort]
       ({(sin(x+90)*sin(x+90))*cos(y)},
        {(sin(x+90)*sin(x+90))*sin(y)},
        {(sin(x+90)*sin(x+90))*sin(x)});
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north east);
    \end{tikzpicture}
\caption{Diagramme de rayonnement du dipole.}
\label{fig:Diagramme de rayonnement du dipole}
    &
% right image
    \begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\draw[-stealth] ([yshift=1.6cm]current axis.south) -- ([yshift=-1.6cm]current axis.north); % corected yshift
    \end{tikzpicture}
\caption{Coupe verticale du diagramme de rayonnement.}
\label{fig:Coupe verticale du diagramme de rayonnement}
\end{tabularx}
    \end{figure}
\end{document}

to obtain above image i comment (removed) package floatrow. Do you really need it? Apparently it somehow redefine appearance of captions in figure environments (allow only one caption) and consequently in above mwe cause errors.

Almost all, for what i see that it is used in your document, can be achieved with subcaption package:

\documentclass[11pt,a4paper]{article}
%\usepackage{floatrow}  % not used in this mwe
                        % however it is troublemaker. do you really need it?
\usepackage{subcaption} % not used in this mwe
\usepackage{tabularx}   % <--- new

 \usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.16}
\usepgfplotslibrary{polar}

\begin{document}
    \begin{figure}[htb]
    \centering
% left image
\begin{subfigure}[b]{0.45\linewidth}
    \begin{tikzpicture}
\begin{axis}[view/h=45,axis lines = none,unit vector ratio=1 1 1]
        \addplot3[domain=0:360,domain y=0:360,samples=31,
        point meta=sqrt(x^2+y^2),
        colormap/blackwhite,surf,%mesh,point meta=1, %<-if you want a mesh
    z buffer=sort]
       ({(sin(x+90)*sin(x+90))*cos(y)},
        {(sin(x+90)*sin(x+90))*sin(y)},
        {(sin(x+90)*sin(x+90))*sin(x)});
\end{axis}
\path(current bounding box.south west) rectangle (current bounding box.north east);
    \end{tikzpicture}
\caption{Diagramme de rayonnement du dipole.}
\label{fig:Diagramme de rayonnement du dipole}
\end{subfigure}
    \hfil
% right image
\begin{subfigure}[b]{0.45\linewidth}
    \begin{tikzpicture}
\begin{polaraxis}[axis lines = none]
\addplot[domain=0:360,samples=73,smooth] (x+90,{sin(x)*sin(x)});
\end{polaraxis}
\draw[-stealth] ([yshift=1.6cm]current axis.south) -- ([yshift=-1.6cm]current axis.north);  % corected yshift
    \end{tikzpicture}
\caption{Coupe verticale du diagramme de rayonnement.}
\label{fig:Coupe verticale du diagramme de rayonnement}
\end{subfigure}
    \caption{Rayonnement du dipole demi-onde.}
    \label{fig:Rayonnement du dipole demi-onde}
    \end{figure}
\end{document}

enter image description here

in both case i slightly corrected second image (see both mwe)

  • I'm just looking for an other way to realize the picture in latex. A different code than the one in the other topic if it's possible. I really need it... – Aurélien Jan 7 at 8:08
  • sorry @Aurélien, i don't understand what is your problem. you already got a number suggestions how to draw dipole radiation diagrams, also how to include include images (this is independent from image contents) in document. beside this you not showing what you try so far and where you stuck in this. you should be more clear, what is your problem. – Zarko Jan 7 at 9:21
  • to continue ... @Aurélien, please provide mwe (minimal working example), a complete small document beginning with \documentclass ... and preamble (with to your problem relevant packages) \begin{document} some dummy text and how you so far inserted your images in document, and ending it with \end{document}. – Zarko Jan 7 at 9:29
  • I have to realise a project about dipole in latex with others people. The problem is that I can't use the code given in the other topic because he needs \subcaption to work. Indeed, in my project somebody else is using \subfigure. \subcaption and \subfigure can't be use at the same time so my project doesn't compile. Does this make sense..? – Aurélien Jan 7 at 9:33
  • @Aurélien, but i show you how to manage this. and without seeing mwe is any discussion worth less. if you will provide it, me or some else will repair it that it will working. – Zarko Jan 7 at 9:38

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.