我想在我的代码中插入用 matlab2tikz 生成的 tikz 图。
这是生成 matlab 图像的代码
X1=[7.4632 8.0349 8.5251 8.8176 9.2251 9.5559 9.9214 10.1924 10.4235 11.0197 12.0898 13.0078 13.9837];
X2=[5.7940 7.0416 8.2893 9.0191 9.5370 9.9386 10.2668 10.5443 10.7846 11.1863 11.7919 12.4340 13.1638];
Y1=[0.025 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.5000 0.7000 1.0000 1.5000];
figure1 = figure;
axes1 = axes('Parent',figure1);
box(axes1,'on');
grid(axes1,'on');
hold(axes1,'all');
% Create plot
plot(X1,Y1,'Parent',axes1,'LineWidth',2,'Color',[0 0 1],...
'DisplayName','Experimental profile');
% Create xlabel
xlabel('Mean wind speed [m/s]','FontSize',12);
% Create ylabel
ylabel('height above the ground [m]','FontSize',12);
% Create plot
plot(X2,Y1,'Parent',axes1,'LineStyle','--','Color',[0 0 1],...
'DisplayName','Log profile z_0= 0.001');
% Create legend
legend1 = legend(axes1,'show');
set(legend1,...
'Position',[0.228476914414414 0.766652157055919 0.396513030888031 0.094037760105238],...
'FontSize',12);
生成的 tikz 代码是
\begin{tikzpicture}
\begin{axis}[%
width=0.00358392700912386in,
height=0.00486727016265824in,
scale only axis,
xmin=5,
xmax=14,
xlabel={Mean wind speed [m/s]},
xmajorgrids,
ymin=0,
ymax=1.5,
ylabel={height above the ground [m]},
ymajorgrids,
legend style={at={(0.228476914414414,0.766652157055919)},anchor=south west,draw=black,fill=white,legend cell align=left}
]
\addplot [color=blue,solid,line width=2.0pt]
table[row sep=crcr]{7.46324069270281 0.025\\
8.03494715464159 0.05\\
8.5251477423859 0.1\\
8.81756139289803 0.15\\
9.22514701029531 0.2\\
9.55588642181522 0.25\\
9.92139059174763 0.3\\
10.1923874711796 0.35\\
10.4235048516839 0.4\\
11.0197367245308 0.5\\
12.0898028668318 0.7\\
13.0078093923308 1\\
13.9837144687306 1.5\\
};
\addlegendentry{Experimental profile};
\addplot [color=blue,dashed]
table[row sep=crcr]{5.79397648476276 0.025\\
7.04164140977066 0.05\\
8.28930633477856 0.1\\
9.01914352937326 0.15\\
9.53697125978646 0.2\\
9.93862965215204 0.25\\
10.2668084543812 0.3\\
10.5442796780702 0.35\\
10.7846361847944 0.4\\
11.1862945771599 0.5\\
11.7919446030781 0.7\\
12.4339595021678 1\\
13.1637966967625 1.5\\
};
\addlegendentry{$\text{Log profile z}_\text{0}\text{= 0.001}$};
\end{axis}
\end{tikzpicture}
我读过这里和网络上许多类似帖子的答案,但问题似乎时有不同。几个小时前我更新了所有软件包,看看新版本的 pgf plot 是否可以解决问题。我也使用最新版本的 matlab2tikz。
你有什么提示给我吗?
非常感谢 再见