繪圖 - 軸上四分之一?

繪圖 - 軸上四分之一?

我是 TEX 新手

我怎麼繪製這個變數並將四分之一保持在x軸上?

date    variable
1993Q1  0.71957432
1993Q2  0.622643199
1993Q3  0.557352546
1993Q4  0.78844216
1994Q1  0.677342246
1994Q2  0.752843835
1994Q3  0.823435891
1994Q4  0.869172377
1995Q1  0.822971248
1995Q2  0.759768686
1995Q3  0.662193784
1995Q4  0.744474674
1996Q1  0.665910923
1996Q2  0.776898876
1996Q3  0.923927404
1996Q4  0.840678042
1997Q1  0.735450535
1997Q2  0.850306776

答案1

這可以透過將ybar資料讀入表格然後繪製表格來實現sharp\pgfplotstableread

在此輸入影像描述

在此輸入影像描述

程式碼

\documentclass{article}%[border=1cm]{standalone}

\usepackage{pgfplots,pgfplotstable}

\pgfplotsset{compat=1.8}

\begin{document}


\pgfplotstableread[col sep=comma]{
date, variable
1993Q1, 0.71957432 
1993Q2, 0.622643199
1993Q3, 0.557352546 
1993Q4, 0.78844216 
1994Q1, 0.677342246 
1994Q2, 0.752843835 
1994Q3, 0.823435891 
1994Q4, 0.869172377 
1995Q1, 0.822971248 
1995Q2, 0.759768686 
1995Q3, 0.662193784 
1995Q4, 0.744474674 
1996Q1, 0.665910923 
1996Q2, 0.776898876 
1996Q3, 0.923927404 
1996Q4, 0.840678042 
1997Q1, 0.735450535 
1997Q2, 0.850306776
}\datatable

% ybar plot
\begin{tikzpicture}
\begin{axis}[
    ybar, 
    height=10cm,
    width=13cm,
    enlarge y limits=false,
    ymin=0,
    ymax=1,
    xtick=data,
    xticklabels from table={\datatable}{date},
    x tick label style={rotate=90, anchor=east}
]
\addplot [fill=blue] table [x expr=\coordindex, y=variable] {\datatable};  

\end{axis}
\end{tikzpicture}%

% -- sharp plot
\begin{tikzpicture}
\begin{axis}[
    height=10cm,
    width=13cm,
    enlarge y limits=false,
    ymin=0,
    ymax=1,
    xtick=data,
    xticklabels from table={\datatable}{date},
    x tick label style={rotate=90, anchor=east}
]
%\addplot [fill=blue] table [x expr=\coordindex, y=variable] {\datatable};  
\addplot [sharp plot] table [x expr=\coordindex, y=variable] {\datatable};  
\end{axis}
\end{tikzpicture}%
\end{document}

相關內容