下面是图表和代码。红色圆圈显示两部分数据。由于上方红色圆圈的数据值>1500,因此下方红色圆圈(0-500)显示所有线条挤在一起。是否可以放大下方红色圆圈(0-500)的部分,以便用户更清楚地看到数据的变化?(同时我需要保留上方红色圆圈部分的数据。)
\begin{tikzpicture}
\begin{axis}[
height=6cm,
width=7cm,
legend pos=outer north east,
legend pos=outer north east,
legend style={draw=none},
ymax=1700,
ymin=200,
xmin=500,
xmax=10000,
%xtick={0,10,20,...,50},
scaled ticks=false,
log ticks with fixed point={100 sep=},
axis x line=bottom,
axis y line=left,
axis line style=-,
minor tick style={draw=none},
ylabel = Running Time (ms),
cycle list={
red,thick, dotted\\
black,thick, densely dotted\\
olive,thick,dashed\\
teal,thick,densely dashed\\
violet,thick,loosely dashed\\
blue,solid\\
},
xlabel = Running Times,
every axis legend/.append style={xshift=-10pt}
]
\addplot+[mystyle] plot coordinates{(500,213.145126666667) (1000,243.28058) (1500,243.147242222222) (2000,239.947061666667) (2500,268.935384) (3000,275.938001111111) (3500,277.158708571429) (4000,270.282125) (4500,275.726881481481) (5000,277.582543333333) (5500,276.246103636364) (6000,278.549265) (6500,273.225883589743) (7000,274.077579047619) (7500,275.402417777778) (8000,276.811665) (8500,276.560914509804) (9000,274.323095185185) (9500,274.69641122807) (10000,278.282580333333) };
\addplot+[mystyle] plot coordinates{(500,203.411986666667) (1000,240.880793333333) (1500,239.125133333333) (2000,235.563816666667) (2500,260.375233333333) (3000,267.993447777778) (3500,269.558616190476) (4000,262.8903775) (4500,268.43051037037) (5000,270.589151333333) (5550,269.561213939394) (6000,271.893672222222) (6500,266.610464102564) (7000,267.501358571428) (7500,268.900168888889) (8000,270.4824825) (8500,269.898136078431) (9000,267.715658148148) (9500 ,268.082345614035) (10000,271.699219333333) };
\addplot+[mystyle] plot coordinates{(500,376.556006666667) (1000,412.458063333333) (1500,411.491344444444) (2000,411.37467) (2500,438.652897333333) (3000,447.015602222222) (3500,450.179274285714) (4000,443.793195) (4500,449.145354074074) (5000,451.486968666667) (5500,450.275383636364) (6000,452.593697777778) (6500,446.693359487179) (7000,447.30768047619) (7500,448.497907111111) (8000,449.589357916667) (8500,449.152323137255) (9000,447.163757407407) (9500,447.184616842105) (10000,450.81693) };
\addplot+[mystyle] plot coordinates{(500,463.6932) (1000,460.42634) (1500,459.781851111111) (2000,471.976995) (2500,482.760948) (3000,479.294082222222) (3500,478.23688) (4000,476.260576666667) (4500,473.715987407408) (5000,470.660256666667) (5500,469.238963030303) (6000,466.304451666667) (6500,463.334195384615) (7000,462.945528571428) (7500,462.239773777777) (8000,461.5514025) (8500,460.830282745098) (9000,459.18923) (9500,457.959530526316) (10000,457.656179)};
\addplot+[mystyle] plot coordinates{(500,468.160453333333) (1000,461.760086666667) (1500,458.337666666667) (2000,466.193673333333) (2500,471.347306666666) (3000,467.182622222222) (3500,466.560363809524) (4000,465.426964166667) (4500,463.145351851852) (5000,460.846700666667) (5500,459.74785030303) (6000,457.032037777778) (6500,454.292992307692) (7000,455.288287619048) (7500,454.510783555556) (8000,454.01381) (8500,453.38705882353) (9000,451.82988962963) (9500,450.664716140351) (10000,450.422772666667)};
\addplot+[mystyle] plot coordinates{(500,1696.64752666667) (1000,1696.71420333333) (1500,1689.89159333333) (2000,1698.13095166667) (2500,1699.96829066667) (3000,1695.20357555555) (3500,1696.08616571429) (4000,1702.98956083333) (4500,1700.36626444444) (5000,1686.04025933333) (5500,1683.2104) (6000,1679.14653111111) (6500,1669.04082564103) (7000,1668.71260095238) (7500,1670.13046044445) (8000,1668.92511333333) (8500,1667.87725882353) (9000,1665.91244074074) (9500,1664.35094842105) (10000,1663.73565033333) };
\legend{A,B,C,D,E,F}
\end{axis}
\end{tikzpicture}
答案1
由于mystyle
不可用,我将其移除以进行运行。此外,数据可以分为两类(第一个 AE 和最后一个 F),提出了两个 y 轴坐标。AE 的 y 轴在左侧,而 F 的 y 轴在右侧,具有 y 轴不连续性特征。
基本思路是先绘制 AE,然后绘制 F。两个轴相互叠加。有关更多详细信息,请查看第 132-135 页的 pgfplots。
代码:
\begin{tikzpicture}
\begin{axis}[
scale only axis,
height=6cm,
width=7cm,
legend pos=north east,
legend style={draw=none},
ymax=500,
ymin=200,
xmin=500,
xmax=10000,
%xtick={0,10,20,...,50},
scaled ticks=false,
log ticks with fixed point={100 sep=},
axis x line=bottom,
axis y line=left,
axis line style=-,
minor tick style={draw=none},
ylabel = Running Time (ms),
cycle list={
red,thick, dotted\\
black,thick, densely dotted\\
olive,thick,dashed\\
teal,thick,densely dashed\\
violet,thick,loosely dashed\\
blue, solid\\
},
xlabel = Running Times,
every axis legend/.append style={xshift=-10pt}
]
\addplot+[] plot coordinates{(500,213.145126666667) (1000,243.28058) (1500,243.147242222222) (2000,239.947061666667) (2500,268.935384) (3000,275.938001111111) (3500,277.158708571429) (4000,270.282125) (4500,275.726881481481) (5000,277.582543333333) (5500,276.246103636364) (6000,278.549265) (6500,273.225883589743) (7000,274.077579047619) (7500,275.402417777778) (8000,276.811665) (8500,276.560914509804) (9000,274.323095185185) (9500,274.69641122807) (10000,278.282580333333) };
\addplot+[] plot coordinates{(500,203.411986666667) (1000,240.880793333333) (1500,239.125133333333) (2000,235.563816666667) (2500,260.375233333333) (3000,267.993447777778) (3500,269.558616190476) (4000,262.8903775) (4500,268.43051037037) (5000,270.589151333333) (5550,269.561213939394) (6000,271.893672222222) (6500,266.610464102564) (7000,267.501358571428) (7500,268.900168888889) (8000,270.4824825) (8500,269.898136078431) (9000,267.715658148148) (9500 ,268.082345614035) (10000,271.699219333333) };
\addplot+[] plot coordinates{(500,376.556006666667) (1000,412.458063333333) (1500,411.491344444444) (2000,411.37467) (2500,438.652897333333) (3000,447.015602222222) (3500,450.179274285714) (4000,443.793195) (4500,449.145354074074) (5000,451.486968666667) (5500,450.275383636364) (6000,452.593697777778) (6500,446.693359487179) (7000,447.30768047619) (7500,448.497907111111) (8000,449.589357916667) (8500,449.152323137255) (9000,447.163757407407) (9500,447.184616842105) (10000,450.81693) };
\addplot+[] plot coordinates{(500,463.6932) (1000,460.42634) (1500,459.781851111111) (2000,471.976995) (2500,482.760948) (3000,479.294082222222) (3500,478.23688) (4000,476.260576666667) (4500,473.715987407408) (5000,470.660256666667) (5500,469.238963030303) (6000,466.304451666667) (6500,463.334195384615) (7000,462.945528571428) (7500,462.239773777777) (8000,461.5514025) (8500,460.830282745098) (9000,459.18923) (9500,457.959530526316) (10000,457.656179)};
\addplot+[] plot coordinates{(500,468.160453333333) (1000,461.760086666667) (1500,458.337666666667) (2000,466.193673333333) (2500,471.347306666666) (3000,467.182622222222) (3500,466.560363809524) (4000,465.426964166667) (4500,463.145351851852) (5000,460.846700666667) (5500,459.74785030303) (6000,457.032037777778) (6500,454.292992307692) (7000,455.288287619048) (7500,454.510783555556) (8000,454.01381) (8500,453.38705882353) (9000,451.82988962963) (9500,450.664716140351) (10000,450.422772666667)};
\legend{A,B,C,D,E}
\end{axis}
\begin{axis}[
axis y discontinuity=crunch, scale only axis,
height=6cm,
width=7cm,
legend pos= south east,
legend style={draw=none},
ymax=1710,
ymin=1650,
xmin=500,
xmax=10000,
%xtick={0,10,20,...,50},
scaled ticks=false,
log ticks with fixed point={100 sep=},
axis x line=bottom,
axis y line=right,
axis line style=-,
minor tick style={draw=none},
ylabel = Second ordinate,
cycle list={
red,thick, dotted\\
black,thick, densely dotted\\
olive,thick,dashed\\
teal,thick,densely dashed\\
violet,thick,loosely dashed\\
blue,solid\\
},
xlabel = Running Times,
every axis legend/.append style={xshift=-10pt}
]
\addplot+[] plot coordinates{(500,1696.64752666667) (1000,1696.71420333333) (1500,1689.89159333333) (2000,1698.13095166667) (2500,1699.96829066667) (3000,1695.20357555555) (3500,1696.08616571429) (4000,1702.98956083333) (4500,1700.36626444444) (5000,1686.04025933333) (5500,1683.2104) (6000,1679.14653111111) (6500,1669.04082564103) (7000,1668.71260095238) (7500,1670.13046044445) (8000,1668.92511333333) (8500,1667.87725882353) (9000,1665.91244074074) (9500,1664.35094842105) (10000,1663.73565033333) };
\addlegendentry{F}
\end{axis}
\end{tikzpicture}