其中 y_max 和 ymin 始终相同,范围从 0.651 到 0.6535,但与图片中不同。x 轴范围从 19.0 到 19:2。
“到目前为止,我只是单独写作,因为我无法让它发挥作用。
\documentclass[a4paper,12pt]{book}
%\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,italian]{babel}
\usepackage{url,amsfonts,epsfig}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{matlab-prettifier}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{0.5pt}
\fancyhead[]{}
\fancyhead[LO]{\nouppercase{\rightmark}}
\fancyhead[RE]{\nouppercase{\leftmark}}
\fancyfoot{}
\fancyfoot[LO,RE]{\thepage}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\parindent 0ex
\usepackage{tikz}
\usepgflibrary{arrows.meta}
\usetikzlibrary{calc,quotes,angles}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[yscale=0.6]
\begin{axis}[name=plot,
xmin=19, xmax=19.2, xlabel={$[s]$}, ylabel={$Ampiezza$},
ymin=0.651,ymax=0.6535,width=1\textwidth]
\addplot[blue,mark=.] table{10Hz.txt};
\end{axis}
\end{tikzpicture}
\caption{\textit{Oscillazioni a 10Hz}}
\label{fig:10Hz}
\begin{tikzpicture}[yscale=0.6]
\begin{axis}[name=plot,
xmin=19, xmax=19.2, xlabel={$[s]$}, ylabel={$Ampiezza$},
ymin=0.651,ymax=0.6535,width=1\textwidth]
\addplot[blue,mark=.] table{20Hz.txt};
\end{axis}
\end{tikzpicture}
\caption{\textit{Oscillazioni a 20Hz}}
\label{fig:20Hz}
\begin{tikzpicture}[yscale=0.6]
\begin{axis}[name=plot,
xmin=19, xmax=19.2, xlabel={$[s]$}, ylabel={$Ampiezza$},
ymin=0.651,ymax=0.6535,width=1\textwidth]
\addplot[blue,mark=.] table{30Hz.txt};
\end{axis}
\end{tikzpicture}
\caption{\textit{Oscillazioni a 30Hz}}
\label{fig:30Hz}
\begin{tikzpicture}[yscale=0.6]
\begin{axis}[name=plot,
xmin=19, xmax=19.2, xlabel={$[s]$}, ylabel={$Ampiezza$},
ymin=0.651,ymax=0.6535,width=1\textwidth]
\addplot[blue,mark=.] table{40Hz.txt};
\end{axis}
\end{tikzpicture}
\caption{\textit{Oscillazioni a 40Hz}}
\label{fig:40Hz}
\begin{tikzpicture}[yscale=0.6]
\begin{axis}[name=plot,
xmin=19, xmax=19.2, xlabel={$[s]$}, ylabel={$Ampiezza$},
ymin=0.651,ymax=0.6535,width=1\textwidth]
\addplot[blue,mark=.] table{50Hz.txt};
\end{axis}
\end{tikzpicture}
\caption{\textit{Oscillazioni a 50Hz}}
\label{fig:50Hz}
\end{figure}
\end{document}
答案1
太棒了,谢谢。我设法做了我需要做的事情。现在我不能做的是在 y 轴上使用 4 位小数:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=1 by 4, % sets number of columns and rows in groupplot array
vertical sep=0pt, % vertical distance between axes
},
axis y line=left, % y axis line on left side only
xmin=0,xmax=10, % set axis
ymin=0, % limits
domain=1:9, % domain, just for example
width=10cm, % width
height=3cm, % and height for each axis
scale only axis, % disregard labels and ticks for scaling
no markers,
enlarge y limits=upper,
]
\nextgroupplot[
ylabel=$y$,
ylabel style={at={(rel axis cs:0,1)},above,rotate=-90}, %move ylabel a bit
axis x line=none] % remove x-axis lines
\addplot{x};
\nextgroupplot[axis x line=none]
\addplot{-x + 10};
\nextgroupplot[axis x line=none]
\addplot{x*x};
\nextgroupplot[
axis x line=bottom, % only x axis line at bottom
xlabel=$x$,
xlabel style={at={(rel axis cs:1,0)},right}]
\addplot+[samples=200] {abs(sin(x*180/pi))};
\end{groupplot}
\end{tikzpicture}
\end{document}