奖励问题

奖励问题

我在下面的绘图中遇到了一点小麻烦。我想更改显示距离的箭头d位于 yz 平面。我不确定如何做到这一点,如果有人能帮助我,那就太好了。图片: 在此处输入图片描述 因此重申一下,我希望下图中红色圆圈内的箭头与 S1 和 S2 位于同一平面上: 在此处输入图片描述 代码:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{3d}

\begin{document}
    \begin{tikzpicture}[scale=1.25,every node/.append style={transform shape}]
        \foreach \x in {-1,-0.75,...,0} {
            \draw (\x,-1) -- (\x,1);
        }
        \draw[fill=black!10] (0.5,-2,-1) -- (0.5,-2,1) -- (0.5,2,1) -- (0.5,2,-1) -- (0.5,-2,-1);
        \fill (0.5,0,0) circle (0.05);
        \foreach \r in {0.25,0.5,...,1.75} {
            \draw (0.5,0) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (2,-2,-1) -- (2,-2,1) -- (2,2,1) -- (2,2,-1) -- (2,-2,-1);
        \fill (2,0.5) circle (0.05) (2,-0.5) circle (0.05);
        \foreach \r in {0.25,0.5,...,2} {
            \draw (2,0.5) ++(-60:\r) arc (-60:60:\r);
            \draw (2,-0.5) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (4,-2,-1) -- (4,-2,1) -- (4,2,1) -- (4,2,-1) -- (4,-2,-1);
%       LABELLING
            \begin{scope}[canvas is yz plane at x=2,rotate=-90]
                \node[above] at (0,0.5) {S${}_1$};
                \node[below] at (0,-0.5) {S${}_2$};
                \draw[|<->|] (-0.5,0.5) -- (-0.5,-0.5) node[midway,right=-0.1cm] {d};
            \end{scope}
            \begin{scope}[canvas is yz plane at x=0.5,rotate=-90]
                \node[below left=-0.1cm] at (0,0) {S${}_0$};
            \end{scope}
        \begin{scope}[xshift=4cm,yshift=2cm,rotate=-90,canvas is xy plane at z=0]
            \fill[white] (0,0) rectangle (4,4);
            \begin{axis}[
                width=5.575cm,
                xmin=-0.5,
                xmax=0.5,
                ticks=none
            ]
                \addplot [samples=1000,blue
                ]
                {(cos(deg(5*pi*sin(deg(x)))))^(2)*((sin(deg(4*pi*sin(deg(x)))))/(4*pi*sin(deg(x))))^(2)};
            \end{axis}
        \end{scope}
        \draw[thin,densely dashed,blue] (2,0) -- (6.9,0);
        \draw[thin,densely dashed,blue] (2,0) -- +(15:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(-15:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(32:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(-32:2.5);
    \end{tikzpicture}
\end{document}

奖励问题

即使有 500 个样本(参见顶点),pgfplots 图像的分辨率也不是很高,是否可以减少样本数量但保留细节?

有关图表的一些信息

该图片展示了物理现象衍射。具体来说,它描述了著名的杨氏双缝实验,并显示了从两个孔的中心到各个角度的强度曲线。

答案1

我认为您正在寻找\pgflowlevelsynccm。(已经有人问过一个非常相似的问题这里

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{3d}

\begin{document}
    \begin{tikzpicture}[scale=1.25,every node/.append style={transform shape}]
        \foreach \x in {-1,-0.75,...,0} {
            \draw (\x,-1) -- (\x,1);
        }
        \draw[fill=black!10] (0.5,-2,-1) -- (0.5,-2,1) -- (0.5,2,1) -- (0.5,2,-1) -- (0.5,-2,-1);
        \fill (0.5,0,0) circle (0.05);
        \foreach \r in {0.25,0.5,...,1.75} {
            \draw (0.5,0) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (2,-2,-1) -- (2,-2,1) -- (2,2,1) -- (2,2,-1) -- (2,-2,-1);
        \fill (2,0.5) circle (0.05) (2,-0.5) circle (0.05);
        \foreach \r in {0.25,0.5,...,2} {
            \draw (2,0.5) ++(-60:\r) arc (-60:60:\r);
            \draw (2,-0.5) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (4,-2,-1) -- (4,-2,1) -- (4,2,1) -- (4,2,-1) -- (4,-2,-1);
%       LABELLING
            \begin{scope}[canvas is yz plane at x=2,rotate=-90]
                \node[above] at (0,0.5) {S${}_1$};
                \node[below] at (0,-0.5) {S${}_2$};
                \pgflowlevelsynccm          
                \draw[|<->|] (-0.5,0.5) -- (-0.5,-0.5) node[midway,right=-0.1cm] {d};
            \end{scope}
            \begin{scope}[canvas is yz plane at x=0.5,rotate=-90]
                \node[below left=-0.1cm] at (0,0) {S${}_0$};
            \end{scope}
        \begin{scope}[xshift=4cm,yshift=2cm,rotate=-90,canvas is xy plane at z=0]
            \fill[white] (0,0) rectangle (4,4);
            \begin{axis}[
                width=5.575cm,
                xmin=-0.5,
                xmax=0.5,
                ticks=none
            ]
                \addplot [samples=1000,blue
                ]
                {(cos(deg(5*pi*sin(deg(x)))))^(2)*((sin(deg(4*pi*sin(deg(x)))))/(4*pi*sin(deg(x))))^(2)};
            \end{axis}
        \end{scope}
        \draw[thin,densely dashed,blue] (2,0) -- (6.9,0);
        \draw[thin,densely dashed,blue] (2,0) -- +(15:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(-15:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(32:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(-32:2.5);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

至于你的评论:你已经说过了every node/.append style={transform shape},所以你需要做的就是把圆圈画成节点。(你可以也可以通过以下方式实现这一点\pgflowlevelsynccm,但根据我的经验,最好只在没有其他选择的情况下才使用它,并且在范围的最后。)

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{3d}

\begin{document}
    \begin{tikzpicture}[scale=1.25,every node/.append style={transform shape}]
        \foreach \x in {-1,-0.75,...,0} {
            \draw (\x,-1) -- (\x,1);
        }
        \draw[fill=black!10] (0.5,-2,-1) -- (0.5,-2,1) -- (0.5,2,1) -- (0.5,2,-1) -- (0.5,-2,-1);
        \fill (0.5,0,0) circle (0.05);
        \foreach \r in {0.25,0.5,...,1.75} {
            \draw (0.5,0) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (2,-2,-1) -- (2,-2,1) -- (2,2,1) -- (2,2,-1) -- (2,-2,-1);
        %\fill (2,0.5) circle (0.05) (2,-0.5) circle (0.05);
        \foreach \r in {0.25,0.5,...,2} {
            \draw (2,0.5) ++(-60:\r) arc (-60:60:\r);
            \draw (2,-0.5) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (4,-2,-1) -- (4,-2,1) -- (4,2,1) -- (4,2,-1) -- (4,-2,-1);
%       LABELLING
            \begin{scope}[canvas is yz plane at x=2,rotate=-90]
                \node[circle,inner sep=0.5mm,fill,label=above:{S${}_1$}] at (0,0.5){};
                \node[circle,inner sep=0.5mm,fill,label=below:{S${}_2$}] at (0,-0.5) {};
                \draw[dash pattern=on 1.5pt off 1pt,thin] (-0.5,0.5) -- (0,0.5)
                (-0.5,-0.5) -- (0,-0.5);
                \pgflowlevelsynccm          
                \draw[|<->|] (-0.5,0.5) -- (-0.5,-0.5) node[midway,right=-0.1cm] {d};
            \end{scope}
            \begin{scope}[canvas is yz plane at x=0.5,rotate=-90]
                \node[below left=-0.1cm] at (0,0) {S${}_0$};
            \end{scope}
        \begin{scope}[xshift=4cm,yshift=2cm,rotate=-90,canvas is xy plane at z=0]
            \fill[white] (0,0) rectangle (4,4);
            \begin{axis}[
                width=5.575cm,
                xmin=-0.5,
                xmax=0.5,
                ticks=none
            ]
                \addplot [samples=1000,blue
                ]
                {(cos(deg(5*pi*sin(deg(x)))))^(2)*((sin(deg(4*pi*sin(deg(x)))))/(4*pi*sin(deg(x))))^(2)};
            \end{axis}
        \end{scope}
        \draw[thin,densely dashed,blue] (2,0) -- (6.9,0);
        \draw[thin,densely dashed,blue] (2,0) -- +(15:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(-15:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(32:2.5);
        \draw[thin,densely dashed,blue] (2,0) -- +(-32:2.5);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

笔记:这不是一个回答最初问题的解决方案,而是一个满足我想在图表中传达的内容的解决方案

我把箭头编辑成一组线,以符合图表的目的。代码和图像如下:

    \begin{tikzpicture}[scale=1.5,every node/.append style={transform shape}]
        \foreach \x in {-0.5,-0.25,0} {
            \draw (\x,-1) -- (\x,1);
        }
        \foreach \x in {-0.375,-0.125,-0.125} {
            \draw[dashed] (\x,-1) -- (\x,1);
        }
        \draw[fill=black!10] (0.5,-2,-1) -- (0.5,-2,1) -- (0.5,2,1) -- (0.5,2,-1) -- (0.5,-2,-1);
        \fill (0.5,0,0) circle (0.05);
        \foreach \r in {0.25,0.5,...,1.75} {
            \draw (0.5,0) ++(-60:\r) arc (-60:60:\r);
        }
        \foreach \r in {0.125,0.375,...,1.875} {
            \draw[dashed] (0.5,0) ++(-60:\r) arc (-60:60:\r);
        }
        \draw[fill=black!10] (2,-2,-1) -- (2,-2,1) -- (2,2,1) -- (2,2,-1) -- (2,-2,-1);
        \fill (2,0.5) circle (0.05) (2,-0.5) circle (0.05);
        \foreach \r in {0.25,0.5,...,2} {
            \draw (2,0.5) ++(-60:\r) arc (-60:60:\r);
            \draw (2,-0.5) ++(-60:\r) arc (-60:60:\r);
        }
        \foreach \r in {0.125,0.375,...,2.125} {
            \draw[dashed] (2,0.5) ++(-60:\r) arc (-60:60:\r);
            \draw[dashed] (2,-0.5) ++(-60:\r) arc (-60:60:\r);
        }
        \draw (2,0.5,0.625) -- (2,0.5,0.5);
        \draw (2,-0.5,0.625) -- (2,-0.5,0.5);
        \draw (2,0.5,0.5) -- (2,-0.5,0.5);
        \draw[densely dotted] (2,0.5,0.5) -- (2,0.5,0);
        \draw[densely dotted] (2,-0.5,0.5) -- (2,-0.5,0);
        \draw[fill=black!10] (4,-2,-1) -- (4,-2,1) -- (4,2,1) -- (4,2,-1) -- (4,-2,-1);
        %       LABELLING
        \begin{scope}[canvas is yz plane at x=2,rotate=-90]
            \node[above] at (0,0.5) {S${}_1$};
            \node[below] at (0,-0.5) {S${}_2$};
            \node[left] at (-0.5,0) {d};
        \end{scope}
        \begin{scope}[canvas is yz plane at x=0.5,rotate=-90]
            \node[below left=-0.1cm] at (0,0) {S${}_0$};
        \end{scope}
        \begin{scope}[xshift=4cm,yshift=2cm,rotate=-90,canvas is xy plane at z=0]
            \fill[white] (0,0) rectangle (4,1);
            \begin{axis}[
                width=5.575cm,
                xmin=-0.62,
                xmax=0.62,
                ymin=0,
                ticks=none
            ]
                \addplot [samples=500,black,smooth
                ]
                    {(cos(deg(5*pi*sin(deg(x)))))^(2)*((sin(deg(4*pi*sin(deg(x)))))/(4*pi*sin(deg(x))))^(2)};
                \draw[thin, densely dashed,blue] (axis cs:0.1593,0.1327) -- (axis cs:0.1593,0);
                \draw[thin, densely dashed,blue] (axis cs:-0.1593,0.1327) -- (axis cs:-0.1593,0);
                \draw[thin, densely dashed,blue] (axis cs:0.3941,0.03938) -- (axis cs:0.3941,0);
                \draw[thin, densely dashed,blue] (axis cs:-0.3941,0.03938) -- (axis cs:-0.3941,0);
            \end{axis}
        \end{scope}
        \draw[thin,densely dashed,blue] (2,0) -- (6.9,0);
        \begin{scope}
            \clip (2,-2) rectangle (4,2);
            \draw[thin,densely dashed,blue] (2,0) --    +(15:4);
            \draw[thin,densely dashed,blue] (2,0) --    +(-15:4);
            \draw[thin,densely dashed,blue] (2,0) --    +(32:4);
            \draw[thin,densely dashed,blue] (2,0) --    +(-32:4);
            \draw[thin,densely dashed,red] (2,0) --     +(8:4);
            \draw[thin,densely dashed,red] (2,0) --     +(-8:4);
            \draw[thin,densely dashed,red] (2,0) --     +(24:4);    
            \draw[thin,densely dashed,red] (2,0) --     +(-24:4);               
        \end{scope}
    \end{tikzpicture}

在此处输入图片描述

(有一些额外的功能,我从原始问题中省略了它们,因为它们使代码变得不必要地混乱)

相关内容