删除 pgfplots 包中 y 轴图例中的空白

删除 pgfplots 包中 y 轴图例中的空白

我正在做一个法国科学学士学位项目,我正在使用该pgfplots软件包根据实验数据创建图表。唯一的问题是小空白处y axis和之间y axis legend我想要减少。插图:

在此处输入图片描述

分数维:

\documentclass{book}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{filecontents}

\begin{document}
\begin{tikzpicture}
\begin{axis}[reverse legend, legend pos=outer north east,xlabel=Temp\'erature (K),
    ylabel=R\'esistivit\'e ($\Omega\ldotp m$)]
\addplot table [mark=diamond,x=T(Kelvin), y=p(omm)]{mydata1.csv};
\end{axis}
\end{tikzpicture}
\end{document}

mydata1.csv 表:

\usepackage{filecontents}
\begin{filecontents*}{mydata1.csv}
T(Kelvin)   R(ohm)  I(mA)   U(V)    p(omm)  Erreur
300.111908  123.8244032 0.010259756 0.001270408 0.00000306465   
297.7685394 122.9174213 0.01025976  0.001261103 0.00000304221
295.7092743 122.111074  0.01025976  0.00125283  0.00000302225
293.6600342 121.3047936 0.01025976  0.001244558 0.00000300229
291.6174927 120.5055767 0.01025976  0.001236358 0.00000298251
289.4931488 119.6788233 0.01025976  0.001227876 0.00000296205
287.4810333 118.9129751 0.01025976  0.001220019 0.0000029431
285.5005188 118.1141763 0.01025976  0.001211823 0.00000292333
283.5370484 117.3530612 0.01025976  0.001204014 0.00000290449
281.4636536 116.569992  0.01025976  0.00119598  0.00000288511
279.4537964 115.7791634 0.01025976  0.001187866 0.00000286553
277.4333191 114.9720827 0.01025976  0.001179586 0.00000284556
275.5073242 114.246133  0.01025976  0.001172138 0.00000282759
273.3582459 113.4217829 0.01025976  0.00116368  0.00000280719
271.3918152 112.6646123 0.01025976  0.001155912 0.00000278845
269.3148346 111.8890087 0.01025976  0.001147954 0.00000276925
267.3946076 111.1346469 0.01025976  0.001140215 0.00000275058
265.4651032 110.3719708 0.01025976  0.00113239  0.00000273171
263.2856751 109.5404597 0.01025976  0.001123859 0.00000271113
261.2316132 108.7550183 0.01025976  0.0011158   0.00000269169
259.3539734 108.0496217 0.01025976  0.001108563 0.00000267423
257.4323273 107.3088932 0.01025976  0.001100963 0.0000026559
255.50103   106.5732513 0.01025976  0.001093416 0.00000263769
253.3363648 105.7395292 0.01025976  0.001084862 0.00000261705
251.3575897 104.9926262 0.01025976  0.001077199 0.00000259857
249.3732071 104.2184463 0.01025976  0.001069256 0.00000257941
247.4745636 103.4883267 0.01025976  0.001061765 0.00000256134
245.3594971 102.6743287 0.01025976  0.001053414 0.00000254119
243.426735  101.932961  0.01025976  0.001045808 0.00000252284
241.3410263 101.1444421 0.01025976  0.001037718 0.00000250332
239.356186  100.4065998 0.01025976  0.001030148 0.00000248506
237.3231583 99.62601658 0.01025976  0.001022139 0.00000246574
235.4331818 98.8888763  0.01025976  0.001014576 0.0000024475
233.362114  98.11108462 0.01025976  0.001006596 0.00000242825
231.3323975 97.32659999 0.01025976  0.000998548 0.00000240883
229.4272232 96.59850361 0.01025976  0.000991077 0.00000239081
227.3316574 95.80512124 0.01025976  0.000982938 0.00000237118
225.3818054 95.06046285 0.01025976  0.000975298 0.00000235275
223.4345779 94.30095271 0.01025976  0.000967505 0.00000233395
221.4108048 93.53698438 0.01025976  0.000959667 0.00000231504
219.4421921 92.78484358 0.01025976  0.00095195  0.00000229642
217.4590454 92.03968185 0.01025976  0.000944305 0.00000227798
215.3803558 91.23667487 0.01025976  0.000936066 0.00000225811
213.3828812 90.4947578  0.01025976  0.000928454 0.00000223975
211.4379197 89.74973422 0.01025976  0.000920811 0.00000222131
209.107666  88.86596548 0.01025976  0.000911743 0.00000219943
207.4768219 84.99870238 0.01025976  0.000872066 0.00000210372
205.4166412 84.4031198  0.01025976  0.000865956 0.00000208898
203.4184876 83.68492162 0.01025976  0.000858587 0.0000020712
201.3683853 82.95291818 0.01025976  0.000851077 0.00000205308
199.3906555 85.16837998 0.01025976  0.000873807 0.00000210792
197.4215775 81.55745096 0.01025976  0.00083676  0.00000201855
195.4246979 83.64539841 0.01025976  0.000858182 0.00000207022
193.4091721 80.15556608 0.01025976  0.000822377 0.00000198385
191.4592285 79.4453634  0.01025976  0.00081509  0.00000196627
189.416298  78.73883167 0.01025976  0.000807842 0.00000194879
187.5027618 78.04701229 0.01025976  0.000800744 0.00000193166
185.4207459 79.84691068 0.01025976  0.00081921  0.00000197621
183.5509262 76.63524816 0.01025976  0.000786259 0.00000189672
181.4522247 75.88216728 0.01025976  0.000778533 0.00000187808
179.400116  75.16626222 0.01025976  0.000771188 0.00000186036
177.4576493 74.46397671 0.01025976  0.000763983 0.00000184298
175.4076386 73.74093954 0.01025976  0.000756564 0.00000182509
173.4234772 73.02875791 0.01025976  0.000749258 0.00000180746
171.4578934 72.33060481 0.01025976  0.000742095 0.00000179018
169.498764  71.6209833  0.01025976  0.000734814 0.00000177262
167.4776917 70.88545745 0.01025976  0.000727268 0.00000175442
165.4774094 70.16833935 0.01025976  0.00071991  0.00000173667
163.4216461 69.42682504 0.01025976  0.000712303 0.00000171831
161.4450913 68.70787726 0.01025976  0.000704926 0.00000170052
159.4932557 67.99043886 0.01025976  0.000697566 0.00000168276
157.5283661 67.27817931 0.01025976  0.000690258 0.00000166513
155.4498291 66.51683214 0.01025976  0.000682447 0.00000164629
153.4990921 65.80501172 0.01025976  0.000675144 0.00000162867
151.5178986 65.07154211 0.01025976  0.000667618 0.00000161052
149.4515686 64.31237347 0.01025976  0.00065983  0.00000159173
147.5473557 63.60507546 0.01025976  0.000652573 0.00000157423
145.5174332 62.85677093 0.01025976  0.000644895 0.00000155571
143.5020752 62.09839905 0.01025976  0.000637115 0.00000153694
141.4623032 61.34112325 0.01025976  0.000629345 0.00000151819
139.4851685 60.58845757 0.01025976  0.000621623 0.00000149956
137.469986  59.82868502 0.01025976  0.000613828 0.00000148076
135.5092545 59.08215623 0.01025976  0.000606169 0.00000146228
133.5715256 58.39769267 0.01025976  0.000599146 0.00000144534
131.4773331 57.52619355 0.01025976  0.000590205 0.00000142377
129.5615921 56.7847973  0.01025976  0.000582598 0.00000140542
127.4931488 55.97292468 0.01025976  0.000574269 0.00000138533
125.5493966 55.18724664 0.01025976  0.000566208 0.00000136588
123.534977  54.36716458 0.01025976  0.000557794 0.00000134559
121.4571915 53.52538396 0.01025976  0.000549158 0.00000132475
119.4993706 52.71046582 0.01025976  0.000540797 0.00000130458
117.480793  51.86073876 0.01025976  0.000532079 0.00000128355
115.5349427 51.00114037 0.01025976  0.000523259 0.00000126228
113.567421  50.11647164 0.01025976  0.000514183 0.00000124038
111.61829   49.22439901 0.01025976  0.000505031 0.0000012183
109.5274353 48.24359903 0.01025976  0.000494968 0.00000119403
107.632309  47.30890691 0.01025976  0.000485378 0.0000011709
105.6254311 46.2711233  0.01025976  0.000474731 0.00000114521
103.6002694 45.13160433 0.01025976  0.000463039 0.00000111701
101.5985298 43.96335369 0.01025976  0.000451053 0.00000108809
99.5330505  42.63177996 0.01025976  0.000437392 0.00000105514
97.61859515 41.18976603 0.01025976  0.000422597 0.00000101945
95.74168015 39.62637138 0.01025976  0.000406557 0.000000980753
93.9788208  37.59261743 0.01025976  0.000385691 0.000000930417
94.29021455 38.04595201 0.01025976  0.000390342 0.000000941637
93.80355835 37.26171365 0.01025976  0.000382296 0.000000922227
93.45417785 36.62334451 0.01025976  0.000375747 0.000000906428
93.17440415 36.08862936 0.01025976  0.000370261 0.000000893194
92.9294014  35.58089172 0.01025976  0.000365051 0.000000880627
92.7803955  35.29938422 0.01025976  0.000362163 0.00000087366
92.6661644  34.9578123  0.01025976  0.000358659 0.000000865206
92.5572624  34.55567316 0.01025976  0.000354533 0.000000855253
92.33444975 33.611381   0.01025976  0.000344845 0.000000831882
92.13410565 32.50830982 0.01025976  0.000333527 0.000000804581
91.96100235 31.20994159 0.01025976  0.000320207 0.000000772446
91.8742332  30.33998856 0.01025976  0.000311281 0.000000750915
91.7685318  28.69273069 0.01025976  0.000294381 0.000000710145
91.65283585 25.58294147 0.01025976  0.000262475 0.000000633178
91.3893776  11.04742582 0.01025976  0.000113344 0.000000273424
91.2399597  2.190880251 0.01025976  0.0000224779    0.0000000542243
91.14022445 0.273660356 0.01025976  0.00000280769   0.00000000677309
90.93209455 0.001975304 0.01025976  0.0000000202661 0.0000000000488888
90.7291107  0.000736062 0.01025976  0.00000000755182    0.0000000000182175
90.5535889  0.001024768 0.01025976  0.0000000105139 0.000000000025363
90.44215775 0.000512516 0.01025976  0.0000000052583 0.0000000000126848
90.254879   0.001196607 0.01025976  0.0000000122769 0.000000000029616
90.13739015 0.000421012 0.01025976  0.00000000431949    0.0000000000104201
89.9364548  -0.000950015    0.01025976  -0.00000000974693   -0.0000000000235129
89.7473564  0.00019151  0.01025976  0.00000000196484    0.00000000000473986
89.6508865  0.000926241 0.01025976  0.00000000950301    0.0000000000229245
89.55620575 0.000269302 0.01025976  0.00000000276298    0.00000000000666523
89.43973925 -0.000316059    0.01025976  -0.00000000324268   -0.00000000000782245
89.33927155 -0.000251087    0.01025976  -0.00000000257609   -0.0000000000062144
89.13487245 -0.000795386    0.01025976  -0.00000000816047   -0.0000000000196858
88.92328265 -0.000643033    0.01025976  -0.00000000659737   -0.0000000000159151
88.73202515 -0.000515612    0.01025976  -0.00000000529006   -0.0000000000127614
88.5379753  0.000916893 0.01025976  0.0000000094071 0.0000000000226931
88.44831845 -0.001134624    0.01025976  -0.000000011641 -0.0000000000280819
88.225296   -0.000352473    0.01025976  -0.00000000361629   -0.00000000000872371
88.0397606  -0.00066449 0.01025976  -0.00000000681751   -0.0000000000164461
87.85322185 -0.000924467    0.01025976  -0.00000000948481   -0.0000000000228806
87.742733   0.000694957 0.01025976  0.00000000713009    0.0000000000172002
87.5308876  -0.000437037    0.01025976  -0.0000000044839    -0.0000000000108167
87.33642575 -0.000626671    0.01025976  -0.0000000064295    -0.0000000000155101
87.14001085 0.000502463 0.01025976  0.00000000515515    0.000000000012436
86.9516563  -0.000483207    0.01025976  -0.00000000495758   -0.0000000000119594
86.8437767  -0.000451336    0.01025976  -0.0000000046306    -0.0000000000111706
86.64901355 0.001306956 0.01025976  0.0000000134091 0.0000000000323472
86.53964235 -0.000456066    0.01025976  -0.00000000467913   -0.0000000000112876
86.4421577  0.00036012  0.01025976  0.00000000369475    0.00000000000891298
86.2262573  0.000639663 0.01025976  0.00000000656279    0.0000000000158317
86.02124785 0.0000523898    0.01025976  0.000000000537507   0.00000000000129665
85.83247375 0.000894302 0.01025976  0.00000000917532    0.000000000022134
85.64301685 0.000557035 0.01025976  0.00000000571504    0.0000000000137866
\end{filecontents*}

答案1

您可以使用选项ylabel near ticksxlabel near ticks将标签移近轴

\documentclass{book}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\begin{axis}[reverse legend,%
             legend pos=outer north east,%
             xlabel=Temp\'erature (K),%
             ylabel=R\'esistivit\'e ($\Omega\ldotp m$),%
             ylabel near ticks]
\addplot{1};
\end{axis}
\end{tikzpicture}
\end{document}

我插入了一条简单的直线,因为这里数据似乎没有必要。

编辑: 正如@Jake 指出的那样,\pgfplotsset{compat=1.12}这也是一个不错的办法。所以我建议你使用这个解决方案,并且不用ylabel near ticks

\documentclass{book}
\usepackage{pgfplots}
\usepackage{tikz}

\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{axis}[reverse legend,%
             legend pos=outer north east,%
             xlabel=Temp\'erature (K),%
             ylabel=R\'esistivit\'e ($\Omega\ldotp m$)]
\addplot{1};
\end{axis}
\end{tikzpicture}
\end{document}

相关内容