我希望在一页中显示两幅图,就像下面的代码中那样,在同一页中使用subcaption
和sidewaysfigure
。第一个问题是 的位置可能有错误sidewaysfigure
,第二个问题是它无法识别我想要包含的最后三列。
此外,鉴于我想在此旁边添加另一个(几乎与这个相同;1 个代表男性,1 个代表女性),我怎样才能拥有一个图例?
\documentclass[12pt,a4paper]{article}
\usepackage[english, greek]{babel}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{tkz-tab}
\usepackage{cancel}
\usepackage{forest}
\usepackage{caption}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{paralist}
\usepackage{pst-tree,array}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{rotating}
\usepackage{chngcntr}
\usepackage{chngcntr}
\usepackage{tkz-euclide}
\usetikzlibrary{shapes.geometric}
\usepackage{tkz-fct} \usetkzobj{all}
\usetikzlibrary{calc,decorations.pathreplacing}
\usetikzlibrary{decorations.markings}
\usepackage{pgfplots}
\usepackage{verbatim}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{filecontents}
\author{Ioannis Galanakis}
\title{}
\date{}
\begin{filecontents*}{book.data
}
exper y_fem_p y_fem_s y_fem_t y_fem_p_11 y_fem_s_11 y_fem_t_11
5 -.0786064 .0543229 .425381
6 -.0923139 .0650023 .5031813
7 -.10535 .07562 .5785562
8 -.0377879 .5229679 .8096244 -.1177149 .086176 .6515059
9 -.0408339 .5803306 .8990896 -.1294085 .0966702 .7220302
10 -.0435072 .6359136 .9859465 -.1404309 .1071028 .7901292
11 -.0458076 .6897169 1.0701950000000000 -.1507819 .1174736 .855803
12 -.0477353 .7417406 1.1518350000000000 -.1604617 .1277827 .9190514
13 -.0492902 .7919847 1.2308660000000000 -.1694702 .13803 .9798745
14 -.0504724 .8404492 1.307290000000000 -.1778074 .1482157 1.038272
15 -.0512817 .887134 1.3811040000000000 -.1854734 .1583396 1.094245
16 -.0517183 .9320391 1.4523110000000000 -.192468 .1684018 1.147792
17 -.0517821 .9751647 1.5209090000000000 -.1987914 .1784023 1.198914
18 -.0514732 1.016510000000000 1.5868980000000000 -.2044435 .1883411 1.24761
19 -.0507914 1.0560770000000000 1.6502790000000000 -.2094244 .1982181 1.293882
20 -.0497369 1.0938630000000000 1.7110520000000000 -.2137339 .2080334 1.337727
21 -.0483096 1.129870000000000 1.7692160000000000 -.2173722 .217787 1.379148
22 -.0465096 1.1640980000000000 1.8247720000000000 -.2203392 .2274789 1.418143
23 -.0443368 1.1965450000000000 1.87772000000000 -.2226349 .2371091 1.454713
24 -.0417912 1.2272140000000000 1.9280590000000000 -.2242594 .2466775 1.488858
25 -.0388728 1.2561020000000000 1.97579000000000 -.2252126 .2561843 1.520577
26 -.0355816 1.2832110000000000 2.0209120000000000 -.2254944 .2656292 1.549872
27 -.0319177 1.30854000000000 2.0634260000000000 -.225105 .2750125 1.57674
28 -.027881 1.3320890000000000 2.1033310000000000 -.2240444 .2843341 1.601184
29 -.0234715 1.3538590000000000 2.1406280000000000 -.2223124 .2935939 1.623202
30 -.0186893 1.373850000000000 2.1753170000000000 -.2199092 .302792 1.642795
31 -.0135343 1.392060000000000 2.2073970000000000 -.2168347 .3119284 1.659962
32 -.0080065 1.4084910000000000 2.2368690000000000 -.2130889 .3210031 1.674704
33 -.0021059 1.4231420000000000 2.2637320000000000 -.2086719 .330016 1.687021
34 .0041675 1.4360140000000000 2.2879870000000000 -.2035835 .3389673 1.696913
35 .0108136 1.4471060000000000 2.3096340000000000 -.1978239 .3478568 1.704379
36 .0178325 1.4564190000000000 2.3286720000000000 -.191393 .3566846 1.70942
37 .0252241 1.4639510000000000 2.3451020000000000 -.1842909 .3654507 1.712036
38 .0329886 1.4697040000000000 2.3589230000000000 -.1765174 .374155 1.712226
39 .0411258 1.4736780000000000 2.3701360000000000 -.1680727 .3827977 1.709991
40 .0496358 1.4758720000000000 2.3787410000000000 -.1589567 .3913786 1.705331
41 .0585185 1.4762860000000000 2.3847370000000000 -.1491694 .3998978 1.698245
42 .0677741 1.4749210000000000 2.3881240000000000 -.1387109 .4083552 1.688734
43 .0774024 1.4717760000000000 2.3889040000000000 -.127581 .416751 1.676798
44 .0874035 1.4668510000000000 2.3870750000000000 -.1157799 .425085 1.662437
45 .0977773 1.4601470000000000 2.3826370000000000 -.1033075 .4333573 1.64565
46 .108524 1.4516630000000000 2.3755910000000000 -.0901638 .4415679 1.626438
47 .1196434 1.4413990000000000 2.3659370000000000 -.0763489 .4497167 1.6048
48 .1311355 1.4293560000000000 2.3536740000000000 -.0618627 .4578039 1.580737
49 .1430005 1.4155330000000000 2.3388030000000000 -.0467052 .4658293 1.554249
50 .1552382 1.39993000000000 2.3213230000000000 -.0308764 .473793 1.525336
51 .1678487 1.3825480000000000 2.3012350000000000 -.0143763 .481695 1.493997
52 .180832 1.3633860000000000 2.2785390000000000 .002795 .4895353 1.460233
53 .1941881 1.3424450000000000 2.2532340000000000 .0206376 .4973138 1.424044
54 .2079169 1.3197240000000000 2.2253210000000000 .0391515 .5050306 1.385429
55 .2220185 1.2952230000000000 2.19480000000000 .0583367 .5126857 1.344389
56 .2364928 1.2689430000000000 2.16167000000000 .0781932 .5202791 1.300924
57 .25134 1.2408830000000000 2.1259310000000000 .0987209 .5278108 1.255034
58 .2665599 1.2110430000000000 2.0875840000000000 .1199199 .5352807 1.206718
59 .2821526 1.1794240000000000 2.0466290000000000 .1417902 .5426889 1.155977
60 .2981181 1.1460250000000000 2.0030660000000000 .1643317 .5500354 1.10281
61 .3144563 1.1108470000000000 1.9568940000000000 .1875446 .5573202 1.047218
62 .3311673 1.0738890000000000 1.9081130000000000 .2114287 .5645432 .9892012
63 .3482511 1.0351510000000000 1.8567240000000000 .2359841 .5717046 .9287588
64 .3657077 .9946333 1.8027270000000000 .2612107 .5788042 .8658911
65 .383537 .9523362 1.7461210000000000 .2871087 .5858421 .8005981
66 .4017392 .9082595 1.6869070000000000 .3136779 .5928183 .7328797
67 .420314 .8624031 1.6250850000000000 .3409185 .5997327 .6627361
68 .4392617 .8147671 1.5606540000000000 .3688302 .6065854 .5901671
69 .4585821 .7653515 1.4936140000000000 .3974133 .6133764 .5151728
70 .4782753 .7141563 1.4239670000000000 .4266676 .6201057 .4377532
71 .4983413 .6611813 1.3517110000000000 .4565932 .6267733 .3579083
72 .5187801 .6064268 1.2768460000000000 .4871902 .6333791 .2756381
73 .5395916 .5498927 1.1993730000000000
74 .5607759 .4915788 1.1192920000000000
75 .582333 .4314854 1.0366020000000000
\end{filecontents*}
\begin{document}
\begin{figure}[ht]
\centering
\begin{sidewaysfigure}
\begin{tikzpicture}
\begin{axis}[
width=0.7\textwidth,
height=6cm,
ymajorgrids,
xmajorgrids,
xlabel={$Experience$},
ylabel={$\ln[wage]$},
title = {Profile},
x tick label style={/pgf/number format/1000 sep=},
ytick scale label code/.code={v},
legend pos=outer north east
]
\addplot[mark=none, red, ultra thick] table[x=exper,y=y_fem_p] {book.data};\addlegendentry{Α'βάθμιας; 2008}
\addplot[mark=none, brown, ultra thick] table[x=exper,y=y_fem_s] {book.data};\addlegendentry{Β' βάθμιας; 2008}
\addplot[mark=none, blue, ultra thick] table[x=exper,y=y_fem_t] {book.data};\addlegendentry{Γ' βάθμιας; 2008}
\addplot[mark=none, green, ultra thick] table[x=exper,y=y_fem_p_11] {book.data};\addlegendentry{Α'βάθμιας; 2011}
\addplot[mark=none, orange, ultra thick] table[x=exper,y=y_fem_s_11] {book.data};\addlegendentry{Β' βάθμιας; 2011}
\addplot[mark=none, purple, ultra thick] table[x=exper,y=y_fem_t_11] {book.data};\addlegendentry{Γ' βάθμιας; 2011}
\end{axis}
\end{tikzpicture}
\end{sidewaystable}
\end{figure}
\end{document}
答案1
像这样吗?
% arara: pdflatex
\documentclass[12pt,a4paper]{article}
\usepackage[english, greek]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{rotating}
\usepackage{mathtools}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usetikzlibrary{pgfplots.groupplots}
\usepackage{filecontents}
\begin{filecontents*}{book.data}
exper y_fem_p y_fem_s y_fem_t y_fem_p_11 y_fem_s_11 y_fem_t_11
5 -.0786064 .0543229 .425381 0 0 0 % added some values here
6 -.0923139 .0650023 .5031813 0 0 0
7 -.10535 .07562 .5785562 0 0 0
8 -.0377879 .5229679 .8096244 -.1177149 .086176 .6515059
9 -.0408339 .5803306 .8990896 -.1294085 .0966702 .7220302
10 -.0435072 .6359136 .9859465 -.1404309 .1071028 .7901292
11 -.0458076 .6897169 1.0701950000000000 -.1507819 .1174736 .855803
12 -.0477353 .7417406 1.1518350000000000 -.1604617 .1277827 .9190514
13 -.0492902 .7919847 1.2308660000000000 -.1694702 .13803 .9798745
14 -.0504724 .8404492 1.307290000000000 -.1778074 .1482157 1.038272
15 -.0512817 .887134 1.3811040000000000 -.1854734 .1583396 1.094245
16 -.0517183 .9320391 1.4523110000000000 -.192468 .1684018 1.147792
17 -.0517821 .9751647 1.5209090000000000 -.1987914 .1784023 1.198914
18 -.0514732 1.016510000000000 1.5868980000000000 -.2044435 .1883411 1.24761
19 -.0507914 1.0560770000000000 1.6502790000000000 -.2094244 .1982181 1.293882
20 -.0497369 1.0938630000000000 1.7110520000000000 -.2137339 .2080334 1.337727
21 -.0483096 1.129870000000000 1.7692160000000000 -.2173722 .217787 1.379148
22 -.0465096 1.1640980000000000 1.8247720000000000 -.2203392 .2274789 1.418143
23 -.0443368 1.1965450000000000 1.87772000000000 -.2226349 .2371091 1.454713
24 -.0417912 1.2272140000000000 1.9280590000000000 -.2242594 .2466775 1.488858
25 -.0388728 1.2561020000000000 1.97579000000000 -.2252126 .2561843 1.520577
26 -.0355816 1.2832110000000000 2.0209120000000000 -.2254944 .2656292 1.549872
27 -.0319177 1.30854000000000 2.0634260000000000 -.225105 .2750125 1.57674
28 -.027881 1.3320890000000000 2.1033310000000000 -.2240444 .2843341 1.601184
29 -.0234715 1.3538590000000000 2.1406280000000000 -.2223124 .2935939 1.623202
30 -.0186893 1.373850000000000 2.1753170000000000 -.2199092 .302792 1.642795
31 -.0135343 1.392060000000000 2.2073970000000000 -.2168347 .3119284 1.659962
32 -.0080065 1.4084910000000000 2.2368690000000000 -.2130889 .3210031 1.674704
33 -.0021059 1.4231420000000000 2.2637320000000000 -.2086719 .330016 1.687021
34 .0041675 1.4360140000000000 2.2879870000000000 -.2035835 .3389673 1.696913
35 .0108136 1.4471060000000000 2.3096340000000000 -.1978239 .3478568 1.704379
36 .0178325 1.4564190000000000 2.3286720000000000 -.191393 .3566846 1.70942
37 .0252241 1.4639510000000000 2.3451020000000000 -.1842909 .3654507 1.712036
38 .0329886 1.4697040000000000 2.3589230000000000 -.1765174 .374155 1.712226
39 .0411258 1.4736780000000000 2.3701360000000000 -.1680727 .3827977 1.709991
40 .0496358 1.4758720000000000 2.3787410000000000 -.1589567 .3913786 1.705331
41 .0585185 1.4762860000000000 2.3847370000000000 -.1491694 .3998978 1.698245
42 .0677741 1.4749210000000000 2.3881240000000000 -.1387109 .4083552 1.688734
43 .0774024 1.4717760000000000 2.3889040000000000 -.127581 .416751 1.676798
44 .0874035 1.4668510000000000 2.3870750000000000 -.1157799 .425085 1.662437
45 .0977773 1.4601470000000000 2.3826370000000000 -.1033075 .4333573 1.64565
46 .108524 1.4516630000000000 2.3755910000000000 -.0901638 .4415679 1.626438
47 .1196434 1.4413990000000000 2.3659370000000000 -.0763489 .4497167 1.6048
48 .1311355 1.4293560000000000 2.3536740000000000 -.0618627 .4578039 1.580737
49 .1430005 1.4155330000000000 2.3388030000000000 -.0467052 .4658293 1.554249
50 .1552382 1.39993000000000 2.3213230000000000 -.0308764 .473793 1.525336
51 .1678487 1.3825480000000000 2.3012350000000000 -.0143763 .481695 1.493997
52 .180832 1.3633860000000000 2.2785390000000000 .002795 .4895353 1.460233
53 .1941881 1.3424450000000000 2.2532340000000000 .0206376 .4973138 1.424044
54 .2079169 1.3197240000000000 2.2253210000000000 .0391515 .5050306 1.385429
55 .2220185 1.2952230000000000 2.19480000000000 .0583367 .5126857 1.344389
56 .2364928 1.2689430000000000 2.16167000000000 .0781932 .5202791 1.300924
57 .25134 1.2408830000000000 2.1259310000000000 .0987209 .5278108 1.255034
58 .2665599 1.2110430000000000 2.0875840000000000 .1199199 .5352807 1.206718
59 .2821526 1.1794240000000000 2.0466290000000000 .1417902 .5426889 1.155977
60 .2981181 1.1460250000000000 2.0030660000000000 .1643317 .5500354 1.10281
61 .3144563 1.1108470000000000 1.9568940000000000 .1875446 .5573202 1.047218
62 .3311673 1.0738890000000000 1.9081130000000000 .2114287 .5645432 .9892012
63 .3482511 1.0351510000000000 1.8567240000000000 .2359841 .5717046 .9287588
64 .3657077 .9946333 1.8027270000000000 .2612107 .5788042 .8658911
65 .383537 .9523362 1.7461210000000000 .2871087 .5858421 .8005981
66 .4017392 .9082595 1.6869070000000000 .3136779 .5928183 .7328797
67 .420314 .8624031 1.6250850000000000 .3409185 .5997327 .6627361
68 .4392617 .8147671 1.5606540000000000 .3688302 .6065854 .5901671
69 .4585821 .7653515 1.4936140000000000 .3974133 .6133764 .5151728
70 .4782753 .7141563 1.4239670000000000 .4266676 .6201057 .4377532
71 .4983413 .6611813 1.3517110000000000 .4565932 .6267733 .3579083
72 .5187801 .6064268 1.2768460000000000 .4871902 .6333791 .2756381
73 .5395916 .5498927 1.1993730000000000
74 .5607759 .4915788 1.1192920000000000
75 .582333 .4314854 1.0366020000000000
\end{filecontents*}
\begin{document}
%\begin{otherlanguage}{english} maybe you have to switch the language here
\begin{sidewaysfigure}[ht]
\centering
\begin{tikzpicture}
\begin{groupplot}[%
,group style={rows=2, vertical sep=2.5cm}
,width=0.7\textwidth
,height=6cm
,ymajorgrids
,xmajorgrids
,xlabel={Experience} % do not put text in $$
,ylabel={$\ln[\text{wage}]$}
,title = {Profile}
,x tick label style={/pgf/number format/1000 sep=}
,ytick scale label code/.code={v}
]
\nextgroupplot[%
,legend to name=grouplegend
,mark=none
]
\addplot[red,ultra thick] table[x=exper,y=y_fem_p] {book.data};\addlegendentry{Α' βάθμιας; 2008} % added space here for better alignment
\addplot[brown, ultra thick] table[x=exper,y=y_fem_s] {book.data};\addlegendentry{Β' βάθμιας; 2008}
\addplot[blue, ultra thick] table[x=exper,y=y_fem_t] {book.data};\addlegendentry{Γ' βάθμιας; 2008}
\addplot[green, ultra thick] table[x=exper,y=y_fem_p_11] {book.data};\addlegendentry{Α' βάθμιας; 2011}
\addplot[orange, ultra thick] table[x=exper,y=y_fem_s_11] {book.data};\addlegendentry{Β' βάθμιας; 2011}
\addplot[purple, ultra thick] table[x=exper,y=y_fem_t_11] {book.data};\addlegendentry{Γ' βάθμιας; 2011}
\nextgroupplot[mark=none]
\addplot[red, ultra thick] table[x=exper,y=y_fem_p] {book.data};
\addplot[brown, ultra thick] table[x=exper,y=y_fem_s] {book.data};
\addplot[blue, ultra thick] table[x=exper,y=y_fem_t] {book.data};
\addplot[green, ultra thick] table[x=exper,y=y_fem_p_11] {book.data};
\addplot[orange, ultra thick] table[x=exper,y=y_fem_s_11] {book.data};
\addplot[purple, ultra thick] table[x=exper,y=y_fem_t_11] {book.data};
\end{groupplot}
\node at (group c1r1.east) [anchor=west, yshift=-3.4cm, xshift=.6cm] {\ref{grouplegend}};
\end{tikzpicture}
\end{sidewaysfigure}
%\end{otherlanguage}
\end{document}