2

I did an easy phase diagram using the area function in Matlab.phase diagram by matlab

I converted it into tikz by using the matlab2tikz function which generates following code:

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}

\begin{document}
\definecolor{mycolor1}{rgb}{0.80000,0.02745,0.11765}%
\definecolor{mycolor2}{rgb}{0.00000,0.32941,0.62353}%
\definecolor{mycolor3}{rgb}{0.96471,0.65882,0.00000}%
%
\begin{tikzpicture}

\begin{axis}[%
width=0.951\fwidth,
height=\fheight,
at={(0\fwidth,0\fheight)},
scale only axis,
area style,
stack plots=y,
xmin=233.5,
xmax=373,
xlabel style={font=\color{white!15!black}},
xlabel={Temperatur in K},
ymin=10,
ymax=100,
ylabel style={font=\color{white!15!black}},
ylabel={Druck in bar},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left
]
\addplot[fill=mycolor1, forget plot] table[row sep=crcr]{%
233.15  10.0449572807974\\
233.65  10.2311604226723\\
234.15  10.419910820566\\
234.65  10.6112298293432\\
235.15  10.8051388592996\\
235.65  11.0016593764163\\
236.15  11.2008129026763\\
236.65  11.40262101634\\
237.15  11.607105352306\\
237.65  11.8142876024392\\
238.15  12.024189516011\\
238.65  12.2368329000626\\
239.15  12.452239619892\\
239.65  12.6704315995169\\
240.15  12.8914308221623\\
240.65  13.1152593308374\\
241.15  13.3419392288892\\
241.65  13.5714926806307\\
242.15  13.8039419119934\\
242.65  14.0393092111895\\
243.15  14.2776169295234\\
243.65  14.5188874821158\\
244.15  14.7631433487671\\
244.65  15.0104070748664\\
245.15  15.2607012723354\\
245.65  15.5140486206\\
246.15  15.7704718677098\\
246.65  16.0299938314666\\
247.15  16.292637400606\\
247.65  16.5584255361207\\
248.15  16.8273812725642\\
248.65  17.0995277195199\\
249.15  17.3748880631124\\
249.65  17.6534855675489\\
250.15  17.9353435768848\\
250.65  18.2204855167035\\
251.15  18.5089348960318\\
251.65  18.800715309221\\
252.15  19.0958504380666\\
252.65  19.3943640538702\\
253.15  19.696280019677\\
253.65  20.0016222926158\\
254.15  20.3104149263206\\
254.65  20.6226820734083\\
255.15  20.9384479881437\\
255.65  21.257737029125\\
256.15  21.5805736621354\\
256.65  21.9069824630462\\
257.15  22.2369881208681\\
257.65  22.5706154408593\\
258.15  22.9078893478257\\
258.65  23.2488348894474\\
259.15  23.5934772397707\\
259.65  23.9418417028017\\
260.15  24.2939537162414\\
260.65  24.6498388552997\\
261.15  25.0095228367234\\
261.65  25.3730315228486\\
262.15  25.7403909259188\\
262.65  26.1116272124481\\
263.15  26.4867667078227\\
263.65  26.8658359009799\\
264.15  27.2488614493982\\
264.65  27.6358701840786\\
265.15  28.0268891149421\\
265.65  28.4219454362785\\
266.15  28.8210665324756\\
266.65  29.2242799840074\\
267.15  29.6316135736501\\
267.65  30.0430952929939\\
268.15  30.4587533492468\\
268.65  30.8786161723633\\
269.15  31.3027124224845\\
269.65  31.7310709978178\\
270.15  32.1637210428348\\
270.65  32.6006919569264\\
271.15  33.0420134035483\\
271.65  33.4877153197651\\
272.15  33.9378279264185\\
272.65  34.3923817387645\\
273.15  34.8514075777466\\
273.65  35.3149365818959\\
274.15  35.7830002198812\\
274.65  36.2556303037572\\
275.15  36.7328590029711\\
275.65  37.2147188591552\\
276.15  37.7012428017034\\
276.65  38.1924641642345\\
277.15  38.6884167019263\\
277.65  39.189134609779\\
278.15  39.694652541889\\
278.65  40.2050056316226\\
279.15  40.7202295129606\\
279.65  41.2403603428287\\
280.15  41.7654348245836\\
280.65  42.295490232739\\
281.15  42.8305644388721\\
281.65  43.3706959389373\\
282.15  43.9159238819835\\
282.65  44.4662881004922\\
283.15  45.0218291425067\\
283.65  45.5825883056086\\
284.15  46.14860767337\\
284.65  46.7199301542868\\
285.15  47.2965995238352\\
285.65  47.8786604701349\\
286.15  48.4661586439104\\
286.65  49.0591407135479\\
287.15  49.6576544261908\\
287.65  50.2617486760408\\
288.15  50.8714735812014\\
288.65  51.4868805704078\\
289.15  52.1080224817306\\
289.65  52.7349536747144\\
290.15  53.3677301583412\\
290.65  54.0064097369511\\
291.15  54.6510521764548\\
291.65  55.3017193932614\\
292.15  55.9584756682715\\
292.65  56.6213878882266\\
293.15  57.2905258165961\\
293.65  57.9659623959605\\
294.15  58.6477740838746\\
294.65  59.3360412243546\\
295.15  60.0308484579183\\
295.65  60.7322851748937\\
296.15  61.4404460204253\\
296.65  62.1554314660586\\
297.15  62.8773484742163\\
297.65  63.606311300521\\
298.15  64.3424425085101\\
298.65  65.0858743174061\\
299.15  65.8367504723084\\
299.65  66.5952289280322\\
300.15  67.361485784085\\
300.65  68.1357211127648\\
301.15  68.9181676535923\\
301.65  69.7091039143388\\
302.15  70.5088742021128\\
302.65  71.3179251945209\\
303.15  72.1368738199136\\
303.65  72.966718263613\\
}
\closedcycle;
\addplot[fill=mycolor2, forget plot] table[row sep=crcr]{%
233.15  89.9550427192026\\
233.65  89.7688395773277\\
234.15  89.580089179434\\
234.65  89.3887701706568\\
235.15  89.1948611407004\\
235.65  88.9983406235837\\
236.15  88.7991870973237\\
236.65  88.59737898366\\
237.15  88.392894647694\\
237.65  88.1857123975607\\
238.15  87.975810483989\\
238.65  87.7631670999374\\
239.15  87.547760380108\\
239.65  87.3295684004831\\
240.15  87.1085691778377\\
240.65  86.8847406691626\\
241.15  86.6580607711108\\
241.65  86.4285073193693\\
242.15  86.1960580880066\\
242.65  85.9606907888105\\
243.15  85.7223830704766\\
243.65  85.4811125178842\\
244.15  85.2368566512329\\
244.65  84.9895929251336\\
245.15  84.7392987276646\\
245.65  84.4859513794\\
246.15  84.2295281322902\\
246.65  83.9700061685334\\
247.15  83.707362599394\\
247.65  83.4415744638793\\
248.15  83.1726187274357\\
248.65  82.9004722804801\\
249.15  82.6251119368876\\
249.65  82.3465144324511\\
250.15  82.0646564231152\\
250.65  81.7795144832965\\
251.15  81.4910651039682\\
251.65  81.199284690779\\
252.15  80.9041495619334\\
252.65  80.6056359461298\\
253.15  80.303719980323\\
253.65  79.9983777073842\\
254.15  79.6895850736794\\
254.65  79.3773179265917\\
255.15  79.0615520118563\\
255.65  78.742262970875\\
256.15  78.4194263378646\\
256.65  78.0930175369539\\
257.15  77.7630118791319\\
257.65  77.4293845591407\\
258.15  77.0921106521743\\
258.65  76.7511651105526\\
259.15  76.4065227602293\\
259.65  76.0581582971983\\
260.15  75.7060462837586\\
260.65  75.3501611447003\\
261.15  74.9904771632766\\
261.65  74.6269684771514\\
262.15  74.2596090740812\\
262.65  73.8883727875519\\
263.15  73.5132332921773\\
263.65  73.1341640990201\\
264.15  72.7511385506018\\
264.65  72.3641298159214\\
265.15  71.9731108850579\\
265.65  71.5780545637215\\
266.15  71.1789334675244\\
266.65  70.7757200159926\\
267.15  70.3683864263499\\
267.65  69.9569047070061\\
268.15  69.5412466507532\\
268.65  69.1213838276367\\
269.15  68.6972875775155\\
269.65  68.2689290021822\\
270.15  67.8362789571652\\
270.65  67.3993080430736\\
271.15  66.9579865964517\\
271.65  66.5122846802349\\
272.15  66.0621720735815\\
272.65  65.6076182612355\\
273.15  65.1485924222534\\
273.65  64.6850634181041\\
274.15  64.2169997801188\\
274.65  63.7443696962428\\
275.15  63.2671409970289\\
275.65  62.7852811408448\\
276.15  62.2987571982966\\
276.65  61.8075358357655\\
277.15  61.3115832980737\\
277.65  60.810865390221\\
278.15  60.305347458111\\
278.65  59.7949943683774\\
279.15  59.2797704870394\\
279.65  58.7596396571713\\
280.15  58.2345651754164\\
280.65  57.704509767261\\
281.15  57.1694355611279\\
281.65  56.6293040610627\\
282.15  56.0840761180165\\
282.65  55.5337118995078\\
283.15  54.9781708574933\\
283.65  54.4174116943914\\
284.15  53.85139232663\\
284.65  53.2800698457132\\
285.15  52.7034004761648\\
285.65  52.1213395298651\\
286.15  51.5338413560896\\
286.65  50.9408592864521\\
287.15  50.3423455738092\\
287.65  49.7382513239592\\
288.15  49.1285264187986\\
288.65  48.5131194295922\\
289.15  47.8919775182694\\
289.65  47.2650463252856\\
290.15  46.6322698416588\\
290.65  45.9935902630489\\
291.15  45.3489478235452\\
291.65  44.6982806067386\\
292.15  44.0415243317285\\
292.65  43.3786121117734\\
293.15  42.7094741834039\\
293.65  42.0340376040395\\
294.15  41.3522259161254\\
294.65  40.6639587756454\\
295.15  39.9691515420817\\
295.65  39.2677148251063\\
296.15  38.5595539795747\\
296.65  37.8445685339414\\
297.15  37.1226515257837\\
297.65  36.3936886994791\\
298.15  35.6575574914899\\
298.65  34.9141256825939\\
299.15  34.1632495276916\\
299.65  33.4047710719678\\
300.15  32.638514215915\\
300.65  31.8642788872352\\
301.15  31.0818323464077\\
301.65  30.2908960856612\\
302.15  29.4911257978873\\
302.65  28.6820748054791\\
303.15  27.8631261800864\\
303.65  27.033281736387\\
}
\closedcycle;
\addplot [color=black, line width=2.0pt, forget plot]
  table[row sep=crcr]{%
233.15  10.0449572807974\\
233.65  10.2311604226723\\
234.15  10.419910820566\\
234.65  10.6112298293432\\
235.15  10.8051388592996\\
235.65  11.0016593764163\\
236.15  11.2008129026763\\
236.65  11.40262101634\\
237.15  11.607105352306\\
237.65  11.8142876024392\\
238.15  12.024189516011\\
238.65  12.2368329000626\\
239.15  12.452239619892\\
239.65  12.6704315995169\\
240.15  12.8914308221623\\
240.65  13.1152593308374\\
241.15  13.3419392288892\\
241.65  13.5714926806307\\
242.15  13.8039419119934\\
242.65  14.0393092111895\\
243.15  14.2776169295234\\
243.65  14.5188874821158\\
244.15  14.7631433487671\\
244.65  15.0104070748664\\
245.15  15.2607012723354\\
245.65  15.5140486206\\
246.15  15.7704718677098\\
246.65  16.0299938314666\\
247.15  16.292637400606\\
247.65  16.5584255361207\\
248.15  16.8273812725642\\
248.65  17.0995277195199\\
249.15  17.3748880631124\\
249.65  17.6534855675489\\
250.15  17.9353435768848\\
250.65  18.2204855167035\\
251.15  18.5089348960318\\
251.65  18.800715309221\\
252.15  19.0958504380666\\
252.65  19.3943640538702\\
253.15  19.696280019677\\
253.65  20.0016222926158\\
254.15  20.3104149263206\\
254.65  20.6226820734083\\
255.15  20.9384479881437\\
255.65  21.257737029125\\
256.15  21.5805736621354\\
256.65  21.9069824630462\\
257.15  22.2369881208681\\
257.65  22.5706154408593\\
258.15  22.9078893478257\\
258.65  23.2488348894474\\
259.15  23.5934772397707\\
259.65  23.9418417028017\\
260.15  24.2939537162414\\
260.65  24.6498388552997\\
261.15  25.0095228367234\\
261.65  25.3730315228486\\
262.15  25.7403909259188\\
262.65  26.1116272124481\\
263.15  26.4867667078227\\
263.65  26.8658359009799\\
264.15  27.2488614493982\\
264.65  27.6358701840786\\
265.15  28.0268891149421\\
265.65  28.4219454362785\\
266.15  28.8210665324756\\
266.65  29.2242799840074\\
267.15  29.6316135736501\\
267.65  30.0430952929939\\
268.15  30.4587533492468\\
268.65  30.8786161723633\\
269.15  31.3027124224845\\
269.65  31.7310709978178\\
270.15  32.1637210428348\\
270.65  32.6006919569264\\
271.15  33.0420134035483\\
271.65  33.4877153197651\\
272.15  33.9378279264185\\
272.65  34.3923817387645\\
273.15  34.8514075777466\\
273.65  35.3149365818959\\
274.15  35.7830002198812\\
274.65  36.2556303037572\\
275.15  36.7328590029711\\
275.65  37.2147188591552\\
276.15  37.7012428017034\\
276.65  38.1924641642345\\
277.15  38.6884167019263\\
277.65  39.189134609779\\
278.15  39.694652541889\\
278.65  40.2050056316226\\
279.15  40.7202295129606\\
279.65  41.2403603428287\\
280.15  41.7654348245836\\
280.65  42.295490232739\\
281.15  42.8305644388721\\
281.65  43.3706959389373\\
282.15  43.9159238819835\\
282.65  44.4662881004922\\
283.15  45.0218291425067\\
283.65  45.5825883056086\\
284.15  46.14860767337\\
284.65  46.7199301542868\\
285.15  47.2965995238352\\
285.65  47.8786604701349\\
286.15  48.4661586439104\\
286.65  49.0591407135479\\
287.15  49.6576544261908\\
287.65  50.2617486760408\\
288.15  50.8714735812014\\
288.65  51.4868805704078\\
289.15  52.1080224817306\\
289.65  52.7349536747144\\
290.15  53.3677301583412\\
290.65  54.0064097369511\\
291.15  54.6510521764548\\
291.65  55.3017193932614\\
292.15  55.9584756682715\\
292.65  56.6213878882266\\
293.15  57.2905258165961\\
293.65  57.9659623959605\\
294.15  58.6477740838746\\
294.65  59.3360412243546\\
295.15  60.0308484579183\\
295.65  60.7322851748937\\
296.15  61.4404460204253\\
296.65  62.1554314660586\\
297.15  62.8773484742163\\
297.65  63.606311300521\\
298.15  64.3424425085101\\
298.65  65.0858743174061\\
299.15  65.8367504723084\\
299.65  66.5952289280322\\
300.15  67.361485784085\\
300.65  68.1357211127648\\
301.15  68.9181676535923\\
301.65  69.7091039143388\\
302.15  70.5088742021128\\
302.65  71.3179251945209\\
303.15  72.1368738199136\\
303.65  72.966718263613\\
};
\addplot[fill=mycolor1, forget plot] table[row sep=crcr]{%
303.65  72.966718263613\\
373.15  72.966718263613\\
}
\closedcycle;
\addplot[fill=mycolor3, forget plot] table[row sep=crcr]{%
303.65  27.033281736387\\
373.15  27.033281736387\\
}
\closedcycle;
\end{axis}
\end{tikzpicture}%
\end{document}

The result looks like this: phase Diagram in latex

What did I do wrong?

  • Are you sure you gave the right MWE? The maximum y value within the values you provide is around 90. However, it seems that the maximum y value is 100 in your Matlab figure. – ferahfeza Feb 23 at 13:14
  • It's because I use the "stack plots = y" option. The maximum y of the figure is 100 over all x values. If I increase the y axis, I can see the two lost areas. Apparently, tikz put the areas on the right hand side of the plot over the plots on the left hand side, starting at x=240 and y = 100 – user182156 Feb 23 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.