我正在写一篇学术文章,我有一个大图表,如果可能的话,应该缩小它的尺寸以适合一列的宽度。我想知道是否可以在轴上应用不同的换行符来减少图表的宽度,更具体地说,在 Y 轴上减少 25 到 45 之间,在 X 轴上减少 1000 到 2000 之间。
附加了 MWE。
\documentclass[10pt, conference, final, a4paper, twocolumn, oneside]{IEEEtran}
\usepackage{pgfplots}
\usepackage{eurosym}
\pgfplotsset{width=7cm,compat=1.8}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{figure*}[!h]
\centering
\begin{tikzpicture}
\begin{axis}[
%title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
height=7cm,
width=\textwidth,
xlabel={Batch Size},
ylabel={Cost per part},
xmin=0, xmax=2250,
ymin=0, ymax=50,
xtick={0,200,500,800,1000,2000},
ytick={0,5,10,15,20,25,45},
yticklabel={\geneuro\pgfmathprintnumber{\tick}},
legend pos=north east,
ymajorgrids=true,
xmajorgrids=true,
grid style=dashed,
]
\addplot + [
color=blue,
smooth,
]
coordinates {
(100,45.14)(200,22.63)(300,15.12)(400,11.37)(500,9.12)(800,5.74)(1000,4.61)(2000,2.36)};
\addplot + [
color=black,
smooth,
]
coordinates {
(100,11.25)(200,10.58)(300,10.35)(400,10.24)(500,10.17)(800,10.07)(1000,10.04)(2000,9.97)};
\addplot + [
color=orange,
smooth,
]
coordinates {
(100,14.70)(200,7.38)(300,4.93)(400,3.71)(500,2.98)(800,1.88)(1000,1.51)(2000,0.78)};
\addplot + [
color=darkgray,
smooth,
]
coordinates {
(100,2.79)(200,1.45)(300,1.00)(400,0.78)(500,0.71)(800,0.61)(1000,0.57)(2000, 0.51)};
\legend{One, Two, Three, Four}
\end{axis}
\end{tikzpicture}
\caption[Break-Even-Analysis]{Break-Even-Analysis .} \label{fig:break-even-analysis}
\end{figure*}
\end{document}
答案1
节省空间的一种方法是使用symbolic x coords
。查看代码中的注释了解其工作原理。
% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
%title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
height=7cm, % <-- I would reduce this size to make it look more square
width=0.5\textwidth, % <-- changed to `0.5\textwidth' to simulate on column width
xlabel={Batch Size},
ylabel={Cost per part},
% ---------------------------------------------------------------------
% % we don't need these
% xmin=0, xmax=2250,
% ymin=0, ymax=50,
% show only ticks at the data point ...
xtick={data},
% ... and use symblic coordinates
symbolic x coords={
100,200,300,400,500,800,1000,2000%
},
% so the `xticklabels' don't overlap, rotate them
xticklabel style={
rotate=90,
},
% % I think we don't need either
% ytick={0,5,10,15,20,25,45},
% ---------------------------------------------------------------------
yticklabel={\pgfmathprintnumber{\tick}\,€},
legend pos=north east,
ymajorgrids=true,
xmajorgrids=true,
grid style=dashed,
smooth, % <-- moved it here, because it is all `\addplot's in common
]
\addplot+ [color=blue] coordinates {
(100,45.14)(200,22.63)(300,15.12)(400,11.37)(500,9.12)(800,5.74)(1000,4.61)(2000,2.36)};
\addplot+ [color=black] coordinates {
(100,11.25)(200,10.58)(300,10.35)(400,10.24)(500,10.17)(800,10.07)(1000,10.04)(2000,9.97)
};
\addplot+ [color=orange] coordinates {
(100,14.70)(200,7.38)(300,4.93)(400,3.71)(500,2.98)(800,1.88)(1000,1.51)(2000,0.78)
};
\addplot+ [color=darkgray] coordinates {
(100,2.79)(200,1.45)(300,1.00)(400,0.78)(500,0.71)(800,0.61)(1000,0.57)(2000, 0.51)
};
\legend{One, Two, Three, Four}
\end{axis}
\end{tikzpicture}
\end{document}