我在尝试使用通用的 y 轴刻度和刻度时遇到了一些问题。我尝试了一些解决方案,例如every plot/.style
确保组图上轴的范围相同,但刻度的位置似乎因每个图而异,从而导致对数据的一些误解。此外,x 轴和 y 轴上的刻度标记会干扰图中的曲线。您能帮我解决这个刻度问题吗?这是代码。
\begin{tikzpicture}[every mark/.append style={mark size=.7pt}]
\begin{groupplot}[scale=0.36, group style={
group name=relcost, group size = 3 by 1, horizontal sep=1cm, %group size=3 by 4
xlabels at=edge bottom, ylabels at=edge left, yticklabels at=edge left, every plot/.style={
ymin=0,
ymax=750000,
enlargelimits=true
}},
xmin=0,xmax=15,
%ymin=0,
ymode = log,
%log ticks with fixed point,
%scaled y ticks=real:1e3,
%ytick={1, 1e+3},
xlabel={Capacity factor},
%ytick={0, 10, 100},
%xticklabels=$\pgfmathprintnumber{\tick}$,
%yticklabel=$\pgfmathprintnumber{\tick}$,
y post scale=0.36,
ylabel={System costs},legend columns=-1,
legend style={font=\small},
% x tick scale label style={
%at={(0.95,0)},yshift=-1.5em,anchor=north,inner sep=0pt
% },
%y tick scale label style={
% at={(-0.05,0.99)},anchor=east,inner sep=0pt,
% },
%scale ticks above exponent={2},
%scaled y ticks=false
]
\nextgroupplot[title=\textsc{C-RAN}, legend to name=unnamed]
% Low-load scenarios
\addplot+ [black, mark=square, mark options={scale=.3, fill=grenadier!30}] coordinates {
(0.0, 750007.1040631207)
(3.0, 120007.1040631207)
(6.0, 20007.104063120714)
(9.0, 7.104063120713099)
(12.0, 7.104063120713099)
(15.0, 7.104063120713099)
};
\addplot+ [cyan, mark=square, mark options={scale=.3, fill=saffron!30}] coordinates {
(0.0, 750173.6040631207)
(3.0, 120173.6040631207)
(6.0, 20173.604063120714)
(9.0, 173.6040631207131)
(12.0, 173.6040631207131)
(15.0, 173.6040631207131)
};
% High load
\addplot+ [magenta, mark=square, mark options={scale=.3, fill=grenadier!30}] coordinates {
(0.0, 750340.1040631207)
(3.0, 120340.1040631207)
(6.0, 20340.104063120714)
(9.0, 340.10406312071314)
(12.0, 340.10406312071314)
(15.0, 340.10406312071314)
};
% \addplot+ [thin, saffron, mark=square, mark options={scale=.3, fill=saffron!30}] coordinates {
% (0, 3.8633)
% (10, 3.6740000000000004)
% (20, 3.6188)
% (30, 3.5742999999999996)
% (40, 3.5340999999999996)
% (50, 3.4966)
% };
\nextgroupplot[title=\textsc{D-RAN}, legend to name=unnamed]
% Low-load scenarios
\addplot+ [black, mark=square, mark options={scale=.3, fill=grenadier!30}] coordinates {
(0.0, 723699.4500521545)
(3.0, 3699.4500521545033)
(6.0, 3699.4500521545033)
(9.0, 3699.4500521545033)
(12.0, 3699.4500521545033)
(15.0, 3699.4500521545033)
};
\addplot+ [cyan, mark=square, mark options={scale=.3, fill=saffron!30}] coordinates {
(0.0, 723745.9702908196)
(3.0, 3745.3708261968736)
(6.0, 3745.3708261968736)
(9.0, 3745.3708261968736)
(12.0, 3745.3708261968736)
(15.0, 3745.3708261968736)
};
% High load
\addplot+ [magenta, mark=square, mark options={scale=.3, fill=grenadier!30}] coordinates {
(0.0, 723792.4905294848)
(3.0, 3791.291600239243)
(6.0, 3791.291600239243)
(9.0, 3791.291600239243)
(12.0, 3791.291600239243)
(15.0, 3791.291600239243)
};
% \addplot+ [thin, saffron, mark=square, mark options={scale=.3, fill=saffron!30}] coordinates {
% (0, 1.5581)
% (10, 1.4588999999999999)
% (20, 1.4384)
% (30, 1.4215)
% (40, 1.4069)
% (50, 1.3936)
% };
\nextgroupplot[title=\textsc{f-RAN}, legend to name=unnamed]
% High load
\addplot+ [black, mark=square, mark options={scale=.3, fill=grenadier!30}] coordinates {
(0.0, 720009.7601891027)
(3.0, 27.482156029028516)
(6.0, 8.98111126865991)
(9.0, 7.092207390984598)
(12.0, 7.092207390984598)
(15.0, 7.092207390984598)
}; \addlegendentry{Cost factor (0)}
\addplot+ [cyan, mark=square, mark options={scale=.3, fill=saffron!30}] coordinates {
(0.0, 720135.5307859082)
(3.0, 143.61324740819705)
(6.0, 135.5307859083099)
(9.0, 135.5307859083099)
(12.0, 135.5307859083099)
(15.0, 135.5307859083099)
}; \addlegendentry{Cost factor (0.6)}
% Low-load
\addplot+ [magenta, mark=square, mark options={scale=.3, fill=grenadier!30}] coordinates {
(0.0, 720227.3887317348)
(3.0, 232.75047401100414)
(6.0, 227.38873173479826)
(9.0, 227.38873173479826)
(12.0, 227.38873173479826)
(15.0, 227.38873173479826)
}; \addlegendentry{Cost factor (1.2)}
% \addplot+ [thin, dashed, saffron, mark=square, mark options={scale=.3, fill=saffron!30}] coordinates {
% (0, 0.5511)
% (10, 0.41609999999999997)
% (20, 0.3845)
% (30, 0.3554)
% (40, 0.333)
% (50, 0.3139)
% };
\end{groupplot}
\node at (relcost c2r1.south) [inner sep=0pt, anchor=north, yshift=-7ex] {\ref{unnamed}};
\end{tikzpicture}
答案1
轴限值不是绘图选项,因此不属于every plot
。我认为every plot
和 轴限值 都不应位于 内group style
。
但是您已经在正确的位置有了xmin
和,所以只需在它们后面添加和即可。当然,这对对数轴不起作用,但看起来不错。您可以使用它来获取 1e0、1e2、1e4 和 1e6 处的刻度。xmax
ymin
ymax
ymin=0
ymin=1
ytickten={0,2,4,6}
在这个例子中,我使用红色和蓝色而不是自定义颜色。
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}[every mark/.append style={mark size=.7pt}]
\begin{groupplot}[
scale=0.36,
group style={
group name=relcost,
group size = 3 by 1,
horizontal sep=1cm, %group size=3 by 4
xlabels at=edge bottom,
ylabels at=edge left,
yticklabels at=edge left
},
ymode = log,
xmin=0,xmax=15,
ymin=1,
ymax=1e7,
ytickten={0,2,4,6},
xlabel={Capacity factor},
y post scale=0.36,
ylabel={System costs},legend columns=-1,
legend style={font=\small},
]
\nextgroupplot[title=\textsc{C-RAN}, legend to name=unnamed]
% Low-load scenarios
\addplot+ [black, mark=square, mark options={scale=.3, fill=blue!30}] coordinates {
(0.0, 750007.1040631207)
(3.0, 120007.1040631207)
(6.0, 20007.104063120714)
(9.0, 7.104063120713099)
(12.0, 7.104063120713099)
(15.0, 7.104063120713099)
};
\addplot+ [cyan, mark=square, mark options={scale=.3, fill=red!30}] coordinates {
(0.0, 750173.6040631207)
(3.0, 120173.6040631207)
(6.0, 20173.604063120714)
(9.0, 173.6040631207131)
(12.0, 173.6040631207131)
(15.0, 173.6040631207131)
};
% High load
\addplot+ [magenta, mark=square, mark options={scale=.3, fill=blue!30}] coordinates {
(0.0, 750340.1040631207)
(3.0, 120340.1040631207)
(6.0, 20340.104063120714)
(9.0, 340.10406312071314)
(12.0, 340.10406312071314)
(15.0, 340.10406312071314)
};
% \addplot+ [thin, red, mark=square, mark options={scale=.3, fill=red!30}] coordinates {
% (0, 3.8633)
% (10, 3.6740000000000004)
% (20, 3.6188)
% (30, 3.5742999999999996)
% (40, 3.5340999999999996)
% (50, 3.4966)
% };
\nextgroupplot[title=\textsc{D-RAN}, legend to name=unnamed]
% Low-load scenarios
\addplot+ [black, mark=square, mark options={scale=.3, fill=blue!30}] coordinates {
(0.0, 723699.4500521545)
(3.0, 3699.4500521545033)
(6.0, 3699.4500521545033)
(9.0, 3699.4500521545033)
(12.0, 3699.4500521545033)
(15.0, 3699.4500521545033)
};
\addplot+ [cyan, mark=square, mark options={scale=.3, fill=red!30}] coordinates {
(0.0, 723745.9702908196)
(3.0, 3745.3708261968736)
(6.0, 3745.3708261968736)
(9.0, 3745.3708261968736)
(12.0, 3745.3708261968736)
(15.0, 3745.3708261968736)
};
% High load
\addplot+ [magenta, mark=square, mark options={scale=.3, fill=blue!30}] coordinates {
(0.0, 723792.4905294848)
(3.0, 3791.291600239243)
(6.0, 3791.291600239243)
(9.0, 3791.291600239243)
(12.0, 3791.291600239243)
(15.0, 3791.291600239243)
};
% \addplot+ [thin, red, mark=square, mark options={scale=.3, fill=red!30}] coordinates {
% (0, 1.5581)
% (10, 1.4588999999999999)
% (20, 1.4384)
% (30, 1.4215)
% (40, 1.4069)
% (50, 1.3936)
% };
\nextgroupplot[title=\textsc{f-RAN}, legend to name=unnamed]
% High load
\addplot+ [black, mark=square, mark options={scale=.3, fill=blue!30}] coordinates {
(0.0, 720009.7601891027)
(3.0, 27.482156029028516)
(6.0, 8.98111126865991)
(9.0, 7.092207390984598)
(12.0, 7.092207390984598)
(15.0, 7.092207390984598)
}; \addlegendentry{Cost factor (0)}
\addplot+ [cyan, mark=square, mark options={scale=.3, fill=red!30}] coordinates {
(0.0, 720135.5307859082)
(3.0, 143.61324740819705)
(6.0, 135.5307859083099)
(9.0, 135.5307859083099)
(12.0, 135.5307859083099)
(15.0, 135.5307859083099)
}; \addlegendentry{Cost factor (0.6)}
% Low-load
\addplot+ [magenta, mark=square, mark options={scale=.3, fill=blue!30}] coordinates {
(0.0, 720227.3887317348)
(3.0, 232.75047401100414)
(6.0, 227.38873173479826)
(9.0, 227.38873173479826)
(12.0, 227.38873173479826)
(15.0, 227.38873173479826)
}; \addlegendentry{Cost factor (1.2)}
% \addplot+ [thin, dashed, red, mark=square, mark options={scale=.3, fill=red!30}] coordinates {
% (0, 0.5511)
% (10, 0.41609999999999997)
% (20, 0.3845)
% (30, 0.3554)
% (40, 0.333)
% (50, 0.3139)
% };
\end{groupplot}
\node at (relcost c2r1.south) [inner sep=0pt, anchor=north, yshift=-7ex] {\ref{unnamed}};
\end{tikzpicture}
\end{document}