TikZ 是否在 PGFPLOTS(连续和离散信号)中提供清晰的科学轴

TikZ 是否在 PGFPLOTS(连续和离散信号)中提供清晰的科学轴

scientific axis = clear是否可以使用 PGFPLOTS重新创建样式?

另外,我想用它subcaption来展示连续和离散信号的例子,但我似乎不知道如何正确地将这些图和子标题居中。有人知道这个问题的解决方案吗?

编辑2:我重新表述了这个问题以便澄清。模仿scientific axis = clear源自的情节风格论点\usetikzlibrary{datavisualization} 确实是可能的,而且在上一个主题. 经过一些调整Torbjørn T.,可以得到如下满意解:

在此处输入图片描述

\documentclass[a4paper,12pt,oneside]{memoir}

%matematički paketi

\usepackage[intlimits]{amsmath}     %omogućava postavljanje granica integrala u formulama
\usepackage{amsthm}         %matematički teoremi, leme i sl.
\usepackage{siunitx}        %podrška za korištenje SI sustava mjernih jedinica

%encoding fontova i jezika
\usepackage[croatian]{babel}
\usepackage[utf8x]{inputenc}        %encoding inputa
\usepackage[enc=utf8]{hrlatex}
\usepackage[T1]{fontenc}        %encoding fontova koji je prikazan u PDF-u
\usepackage{amsfonts}
\usepackage{dsfont}

\usepackage[fixlanguage]{babelbib}
\selectbiblanguage{croatian}
\OnehalfSpacing

%\usepackage[datetime2-croatian]{datetime2}

%paketi tablica, naslova, poglavlja i sl.
\usepackage[thinlines]{easytable}
\usepackage{tocloft}        %upravljanje izgledom tablice sadržaja
\usepackage{pdfpages}       %integracija eksternih PDF-ova
\usepackage{booktabs}       %koristi se za formatiranje tablica sukladno standardu za znanstvene radove i članke
\usepackage{indentfirst}     %dodaje tab za svaku prvu rečenicu odlomka
\usepackage{subcaption}     %koristi se za podnaslove slika, formi i sl.
\usepackage[font=it]{caption}
\captionsetup[table]{position=above}
\captionsetup[figure]{position=below}
\captionsetup{labelsep=period}

\usepackage[hidelinks]{hyperref}        %podrška za integraciju hyperlinkova
\urlstyle{same}

\usepackage{float}
%grafički paketi
% \usepackage{pgfcore}
% \usepgflibrary{datavisualization.formats.functions}
\usepackage{graphicx}
\usepackage{pgfmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\pgfplotsset{
    standard/.style={
        width = 7cm,
        semithick,
        tick style={major tick length=4pt,semithick,black},
        every axis plot post/.style={mark options={fill=black}},
        separate axis lines,
        axis x line*=bottom,
        axis x line shift=10pt,
        %xlabel shift=5pt,
        axis y line*=left,
        axis y line shift=10pt,
        %ylabel shift=0pt,
        xtick align = outside,
        ytick align = outside,
        xlabel near ticks,
        ylabel near ticks,
        xmin = -1, xmax = 1,
        ymin = -1, ymax = 1,
        grid
    }
}
\usepackage{tikz}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\usetikzlibrary{arrows,automata,patterns,positioning}
\usepackage{circuitikz}
\newcommand{\pgfmathparseFPU}[1]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathparse{#1}%
\pgfmathsmuggle\pgfmathresult\endgroup}


%misc. paketi

\usepackage{soul} %žuti marker
\usepackage{times}

%formatiranje dokumenta
\pagestyle{myheadings}
\setulmarginsandblock{2.5cm}{2.5cm}{*}
\setlrmarginsandblock{2.5cm}{2cm}{*}
\checkandfixthelayout

\setlength{\parskip}{6pt} %razmak između odlomaka

\usepackage{titlesec}   %nadomješta LaTeX makroe za naslove, odlonke, itd.

\titleformat{\chapter}
{\normalfont\fontsize{14}{14}\bfseries}
{\thechapter}
{1em}
{}
\titlespacing{\chapter}{0pt}{*4}{*1}
\titleformat{\section}
{\normalfont\fontsize{12}{14}\bfseries}
{\thesection}
{1em}
{}
\titlespacing{\section}{0pt}{*4}{*1}
\setsecnumdepth{subsection}
\maxtocdepth{subsection}
\titleformat{\subsection}
{\normalfont\fontsize{12}{14}}
{\thesubsection}
{1em}
{}
\titlespacing{\subsection}{0pt}{*4}{*1}

\begin{document}
    \begin{figure}[H]
        %\centering
        \begin{minipage}[b] {.4\linewidth}
            \centering
            \begin{tikzpicture}
                \begin{axis}[
                    standard,
                    xlabel={$n$},
                    ylabel={$x[n]$},
                    enlarge x limits=false,
                    domain = -1:1,
                    samples = 21,                         
                ],
                    \addplot [smooth, black, thick] {sin(2*180*x)};
                \end{axis} 
            \end{tikzpicture}
            \subcaption{Continous signal}
            \label{fig:M31}
        \end{minipage}
        \qquad\qquad
        \begin{minipage}[b] {.4\linewidth}
            \centering
            \begin{tikzpicture}
                \begin{axis}[
                    standard,
                    xlabel={$n$},
                    ylabel={$x[n]$},
                    enlarge x limits=false,
                    domain = -1:1,
                    samples = 21,                         
                ],
                    \addplot+[ycomb, black, thick] {sin(2*180*x)};
                \end{axis} 
            \end{tikzpicture}
            \subcaption{Discrete signal}      
            \label{fig:M32}
        \end{minipage}
        \caption{Main caption}
        \label{fig:M3}    
    \end{figure}
\end{document}

答案1

如果我正确理解了你的问题,你只需要替换minipagesubfigure

\documentclass[a4paper,12pt,oneside]{memoir}

\usepackage{subcaption}     % koristi se za "subfigure" i "subtable"
\usepackage[font=it]{caption}
\captionsetup[table]{position=above}
\captionsetup[figure]{position=below}
\captionsetup{labelsep=period}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\pgfplotsset{
    standard/.style={
        width = 0.9\linewidth,  % <---
        semithick,
        tick style={major tick length=4pt,semithick,black},
        every axis plot post/.style={mark options={fill=black}},
        separate axis lines,
        axis x line*=bottom,
        axis x line shift=5pt,  % <---
        %xlabel shift=5pt,
        axis y line*=left,
        axis y line shift=5pt,  % <---
        ylabel shift=-5pt,      % <---
        xtick align = outside,
        ytick align = outside,
        xlabel near ticks,
        ylabel near ticks,
        xmin = -1, xmax = 1,
        ymin = -1, ymax = 1,
        grid
    }
}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{figure}[ht]
    \centering
        \begin{subfigure}[b]{.48\linewidth} % <---
            \begin{tikzpicture}
                \begin{axis}[
                    standard,
                    xlabel={$t$},
                    ylabel={$x(t)$},
                    enlarge x limits=false,
                    domain = -1:1,
                    samples = 21,
                ],
                    \addplot [smooth, black, thick] {sin(2*180*x)};
                \end{axis}
            \end{tikzpicture}
            \caption{Continous signal}  % <---
            \label{fig:M31}
        \end{subfigure}
\hfill
        \begin{subfigure}[b]{.48\linewidth} % <---
            \begin{tikzpicture}
                \begin{axis}[
                    standard,
                    xlabel={$n$},
                    ylabel={$x[n]$},
                    enlarge x limits=false,
                    domain = -1:1,
                    samples = 21,
                ],
                    \addplot+[ycomb, black, thick] {sin(2*180*x)};
                \end{axis}
            \end{tikzpicture}
            \caption{Discrete signal} % <---
            \label{fig:M32}
        \end{subfigure}
        \caption{Main caption}
        \label{fig:M3}
    \end{figure}
\end{document}    

与您的 MWE 相比,上述 MWE 的变化在代码中用 标记% <---。题外话:据我了解,离散信号在第二幅图中的标签表示信号间隔,而不是离散时刻n。可能应该有 `$N_0$。

在此处输入图片描述

相关内容