我想绘制一些测量值。y 轴包含电压,x 轴包含时间戳。我曾经matlab2tikz
创建过这个图:
如果我想绘制图表,x 轴不会缩放到文本宽度。我该如何缩放它以便在xmin
和之间使用完整的文本宽度xmax
?
感谢所有的建议
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}
\newlength\figureheight
\newlength\figurewidth
\begin{document}
\setlength\figureheight{0.35\textheight}
\setlength\figurewidth{0.9\textwidth}
\begin{tikzpicture}
\begin{axis}[%
width=\figurewidth,
height=\figureheight,
unbounded coords=jump,
view={0}{90},
%scale only axis,
%xscale=1,
xmin=735340.365497685,
xmax=735340.875439815,
xtick= {735340.465497685,735340.4999357,735340.534373714,735340.568811728,735340.603249743,73534 0.637687757,735340.672125772,735340.706563786,735340.7410018,735340.775439815},
xticklabels= {11:10:19,11:59:54,12:49:29,13:39:05,14:28:40,15:18:16,16:07:51,16:57:27,17:47:02,18:36:3 8},
%enlargelimits=false,
ymin=46,
ymax=58,
ylabel={Spannung [V]},
%zmin=-1,
%zmax=2,
name=plot1
]
\addplot [
color=blue,
solid,
forget plot
]
table[row sep=crcr]{
735340.464791667 49.9\\
735340.465497685 49.9\\
735340.466203704 49.9\\
735340.466909722 49.9\\
735340.467615741 49.9\\
735340.468310185 49.9\\
735340.469050926 49.9\\
735340.469756944 49.9\\
735340.470451389 49.9\\
735340.471157407 49.7\\
735340.471863426 49.5\\
735340.472569444 48.8\\
735340.473263889 49.2\\
735340.473969907 48.8\\
735340.474675926 48.4\\
735340.475381944 48.4\\
735340.476111111 48.3\\
735340.47681713 48.1\\
735340.477523148 48\\
735340.478217593 47.8\\
735340.478923611 48\\
735340.479618056 49.1\\
735340.480324074 49.4\\
735340.481030093 49.3\\
735340.481724537 49.2\\
735340.482430556 48.6\\
735340.483171296 48.7\\
735340.483877315 48.7\\
735340.484583333 50.6\\
735340.485277778 53.6\\
735340.485983796 54.3\\
735340.486689815 53.4\\
735340.487384259 53.9\\
735340.488090278 54.4\\
735340.488796296 54.5\\
735340.489502315 54.5\\
735340.490231482 54.5\\
735340.490925926 54.4\\
735340.491631944 54.5\\
735340.492337963 54.5\\
735340.493032407 54.5\\
735340.493738426 54.5\\
735340.49443287 54.5\\
735340.495138889 54.6\\
735340.495833333 54.6\\
735340.496585648 54.6\\
735340.497291667 54\\
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
(写这个答案是为了解释问题的原因,并总结我们在评论中经历的事情。)
问题出在pgfplots
轴包含太多数字的值的包中(参见手动的了解详情)。解决此问题的一种方法是重新调整要xticks
使用 matlab 绘制的点的值和 x 坐标。这可以通过使用类似以下的线性函数来实现
f(x)=(x-x最小)/(x最大-x最小)*100
然后,如果您不触碰 xticklabels,此转换将在 pdf 上透明,但可以消除pgfplots
包中的“尺寸太大”错误。这还应该允许您在修改图形宽度时从图形中获得一些响应。