加熱斜坡圖,增加軸心和減少軸

加熱斜坡圖,增加軸心和減少軸

首先讓我澄清一下,我不知道如何正確地用英語命名它,所以請隨意編輯標題或發表評論。

我需要以加熱和冷卻 (Tr) 顯示在同一軸上的方式繪製這些數據,並且同一方向。看圖片。我找不到一種方法讓 x 軸達到 900,然後減少回來,同時仍然從左到右。

如果我按時間 (t) 繪圖,我只能得到所需的結果,但是,我需要一個顯示溫度的軸。

我嘗試過分成兩個情節並對其進行鏡像,但這會花費我太多的時間來處理將來類似的其他情節。除了不太優雅之外,在複雜曲線的情況下視覺效果也很差。

在此輸入影像描述

\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}

在此輸入影像描述

相關內容