![加熱ランププロット、増加軸と減少軸](https://rvso.com/image/405363/%E5%8A%A0%E7%86%B1%E3%83%A9%E3%83%B3%E3%83%97%E3%83%97%E3%83%AD%E3%83%83%E3%83%88%E3%80%81%E5%A2%97%E5%8A%A0%E8%BB%B8%E3%81%A8%E6%B8%9B%E5%B0%91%E8%BB%B8.png)
まず最初に、英語でこれに適切な名前を付ける方法がわからないことを明確にしておきます。そのため、タイトルを編集したり、コメントを残したりしてください。
このデータを、加熱と冷却(Tr)が同じ軸に表示されるようにプロットする必要があります。同じ方向画像を参照してください。左から右に移動しながら、x 軸を 900 まで移動させてから減少させる方法が見つかりませんでした。
時間 (t) でプロットした場合にのみ目的の結果を得ることができますが、温度を示す軸が必要です。
2 つのプロットに分割してミラーリングしてみましたが、将来的にこのようなプロットを作成すると時間がかかりすぎます。また、複雑な曲線の場合、見た目があまりエレガントではなく、見栄えも良くありません。
\documentclass[]{standalone}
% UNITS
\usepackage{siunitx}
\sisetup{per-mode=fraction, abbreviations}
% GRAPHICS
\usepackage{pgfplots}
\pgfplotsset{width=9cm,height=6cm,compat=newest}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
\usepackage{filecontents}
\begin{filecontents}{datax.dat}
t,HF,Gewicht,Normal,DTG,Tr
574,1.20838,8.47718,0.981320918,-0.00509898,67.8333
3794,27.9521,2.06633,0.239198985,-0.009580838,372.333
6944,6.17274,0.420004,0.04861979,0,897.333
6964,3.65761,0.419016,0.048505419,0,900
7424,-19.0714,0.413001,0.047809121,0,900
13984,-28.3111,0.367016,0.0424858830,900
15194,-4.02426,0.321001,0.037159173,0,727.667
17074,28.3149,0.190241,0.022022356,0,414.333
18914,13.0023,-0.164632,-0.01905785,0,107.667
\end{filecontents}
\begin{document}
{\footnotesize
\begin{tikzpicture}
\bigskip
\pgfplotsset{
scale only axis,
minor x tick num=3,
}
\begin{axis}[
axis y line*=left,
ymin=-0.1, ymax=1.1,
minor y tick num=4,
xlabel=Time (\si{\second}),
%xlabel=Temperature (\si{\degreeCelsius}),
ylabel=\ref{TGA} Mass ($\%$),
,
]
\addplot [smooth,thick,cyan,] table [,x=t, y=Normal, col sep=comma] {datax.dat};
\label{TGA}
\end{axis}
\begin{axis}[
axis y line*=right,
minor y tick num=4,
ylabel=\ref{DTG} Derivative Mass ($\% /\ \si{\degreeCelsius}$),
]
\addplot [smooth,thick,dashed,green!60!black,] table [x=t, y=HF, col sep=comma] {datax.dat};
\label{DTG};
\end{axis}
\end{tikzpicture}
}
\end{document}
答え1
これは、温度を時間の関数として上側のx軸に追加します。温度は等間隔ではないため、重なり合う目盛りは非表示になっています。最小距離は次のようにエンコードされます。
\pgfmathtruncatemacroFPU{\itest}{ifthenelse(abs(\Time/10000-\LastTime/10000)>0.1,1,0)}%
また、データ ファイルの で始まる行には13984
5 つの要素しかないことにも注意してください。要素を追加しました。このコードを実行するときは、データ ファイルを実際に上書きしていることを確認してください。元のデータ セットではエラーが発生しますunbalanced columns
。
\documentclass[]{standalone}
% UNITS
\usepackage{siunitx}
\sisetup{per-mode=fraction, abbreviations}
% GRAPHICS
\usepackage{pgfplots}
\pgfplotsset{width=9cm,height=6cm,compat=newest}
% Style to select only points from #1 to #2 (inclusive)
\pgfplotsset{select coords between index/.style 2 args={
x filter/.code={
\ifnum\coordindex<#1\def\pgfmathresult{}\fi
\ifnum\coordindex>#2\def\pgfmathresult{}\fi
}
}}
\usepackage{filecontents}
\begin{filecontents*}{datax.dat}
t,HF,Gewicht,Normal,DTG,Tr
574,1.20838,8.47718,0.981320918,-0.00509898,67.8333
3794,27.9521,2.06633,0.239198985,-0.009580838,372.333
6944,6.17274,0.420004,0.04861979,0,897.333
6964,3.65761,0.419016,0.048505419,0,900
7424,-19.0714,0.413001,0.047809121,0,900
13984,-28.3111,0.367016,0.0424858830,0,900
15194,-4.02426,0.321001,0.037159173,0,727.667
17074,28.3149,0.190241,0.022022356,0,414.333
18914,13.0023,-0.164632,-0.01905785,0,107.667
\end{filecontents*}
\newcommand*{\ReadOutElement}[4]{%
\pgfplotstablegetelem{#2}{[index]#3}\of{#1}%
\let#4\pgfplotsretval
}
\def\pgfmathtruncatemacroFPU#1#2{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathtruncatemacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}%
\begin{document}
{\footnotesize%<- am not sure about this one
\begin{tikzpicture}
\pgfplotstableread[header=true,col sep=comma]{datax.dat}{\datatable}%
\pgfplotstablegetrowsof{\datatable}%
\pgfmathtruncatemacro{\numrows}{\pgfplotsretval}%
\pgfplotsforeachungrouped \iloop in {0,...,\the\numexpr\numrows-1}
{\ReadOutElement{\datatable}{\iloop}{0}{\Time}%
\ReadOutElement{\datatable}{\iloop}{5}{\Temp}%
\pgfmathtruncatemacro{\Temp}{\Temp}%
\ifnum\iloop=0
\edef\LstTimes{\Time}
\edef\LstTemps{\Temp}
\edef\LastTime{\Time}
\else
\pgfmathtruncatemacroFPU{\itest}{ifthenelse(abs(\Time/10000-\LastTime/10000)>0.1,1,0)}%
\ifnum\itest=1
\edef\LstTimes{\LstTimes,\Time}
\edef\LstTemps{\LstTemps,\Temp}
\edef\LastTime{\Time}
\fi
\fi}
%\pgfmathsetmacro{\LstTemps}{{\LstTemps}[0]}
% \show\LstTemps
%\typeout{\LstTimes,\LstTemps}
\pgfplotsset{
scale only axis,
minor x tick num=3,
}
\begin{axis}[
axis y line*=left,
ymin=-0.1, ymax=1.1,
minor y tick num=4,
xlabel=Time (\si{\second}),
ylabel=\ref{TGA} Mass ($\%$),
,
]
\addplot [smooth,thick,cyan,] table [,x=t, y=Normal, col sep=comma] {datax.dat};
\label{TGA}
\end{axis}
\begin{axis}[
axis y line*=right,
minor y tick num=4,
axis x line*=right,scaled ticks = false,
xlabel={Temperature (\si{\degreeCelsius})},
xtick=\LstTimes,xticklabels/.expanded=\LstTemps,
%xticklabel style={/pgf/number format/precision = 0},
ylabel=\ref{DTG} Derivative Mass ($\% /\ \si{\degreeCelsius}$),
]
\addplot [smooth,thick,dashed,green!60!black,] table [x=t, y=HF, col sep=comma] {datax.dat};
\label{DTG};
\end{axis}
\end{tikzpicture}
}
\end{document}