我在使用 tikz 绘制曲线时遇到问题。我得到的只是图例,但没有曲线,也没有图形或轴......
欢迎任何帮助!谢谢
以下是(简化的)代码
%%% TikZ packages and styles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots}
\usepackage{tikz-3dplot}
\tdplotsetmaincoords{70}{120}
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\usetikzlibrary{decorations}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{plotmarks}
% TikZ styles (nodes and squares)
\tikzstyle{itnode}=[circle,thick,draw]
\tikzstyle{itnodesq}=[rectangle,thick,text centered,text width=5em,minimum height=3em,draw]
\tikzstyle{init} = [pin edge={<-,thin,black}]
\begin{document}
\setlength{\figurewidth}{0.65\columnwidth}
\begin{figure}[h!]
\begin{center}
\scriptsize
\begin{tikzpicture} \begin{axis}[
width=\figurewidth,
height=0.48830242510699\figurewidth,
scale only axis,
xmin=5, xmax=10,
xlabel={Temps (s)},
xmajorgrids,
ymin=40, ymax=95,
ylabel={Y},
ymajorgrids,
axis lines*=left,
legend style={at={(1.03,1)},anchor=north west,draw=black,fill=white,legend cell align=left}]
\addplot [
color=blue,
solid
]
coordinates{
(4.98725704809287,67)
(5.00027860696517,66)
(5.01330016583748,64)
(5.02632172470978,64)};
\addlegendentry{Node 2};
\addplot [
color=green!50!black,
solid]
coordinates{
(4.98725704809287,89)
(5.00027860696517,81)
(5.01330016583748,82)
(5.02632172470978,82)};
\addlegendentry{Node 3};
\end{axis}
\end{tikzpicture}%
\end{center}
\label{fig:example_plot}
\end{figure}
\end{document}
答案1
我怀疑你期望的是这样的:
- 由于您的
\figurewidth
身份不明,我使用默认图像尺寸 xmin
正如您在上面的评论中所看到的,您的坐标范围与声明的范围相比非常小xmax
,因此绘制的圆圈(它存在于您的图像上)几乎是不可见的- 从你的代码片段中我删除了所有与此图不相关的内容
梅威瑟:
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\scriptsize
\begin{tikzpicture}
\begin{axis}[
% width=\figurewidth,
% height=0.48830242510699\figurewidth,
scale only axis,
% xmin=4, xmax=6,
xlabel={Temps (s)},
xmajorgrids,
ymin=60, ymax=90,
ylabel={Y},
ymajorgrids,
axis lines*=left,
legend style={at={(1.03,1)},anchor=north west,draw=black,fill=white,legend cell align=left}]
\addplot[
color=blue,
solid
]
coordinates{
(4.98725704809287,67)
(5.00027860696517,66)
(5.01330016583748,64)
(5.02632172470978,64)};
\addplot[
color=green!50!black,
solid]
coordinates{
(4.98725704809287,89)
(5.00027860696517,81)
(5.01330016583748,82)
(5.02632172470978,82)};
\legend{Node2, Node 3};
\end{axis}
\end{tikzpicture}
\end{document}