2017-05-18 9 views
0

.csv 파일의 데이터를 사용하여 숫자가 아닌 레이블이있는 barchart를 생성하려고합니다. 몇 가지 예를 살펴 보았지만 크고 멍청한 것처럼 보입니다. 나는 더 좋은 방법이 있기를 바라고 있습니다. 오류 얻을LaTeX pgfplots은 .csv의 barchart 레이블에 문자열을 사용합니다.

\documentclass[11pt]{article} 
\usepackage{pgfplots} 
\pgfplotsset{compat=1.9} 

\begin{document} 
\begin{tikzpicture} 
\begin{axis}[xlabel=x axis label,ylabel=y axis label] 
\addplot [ybar] table [symbolic x coords=Month, y=Dozers, col sep=comma] {cnrldata.csv}; 
\end{axis} 
\end{tikzpicture} \\ 
\end{document} 

물론이 I에서 : : 여기가 MWE로 지금까지이 무엇을 테이블에

Package PGF Math Error: Could not parse input 'May 14' as a floating point number, sorry. The unreadable part was near 'May 14'.. ... y=Dozers, col sep=comma] {data.csv}; 

데이터는 다음과 같습니다

Month, Dozers, 
January, 0.85, 
February, 0.7, 

답변

0

귀하 symbolic x coords의 사용법이 잘못되었습니다. manual을 읽으십시오.

팁 :TeX.SX과 같은 질문에 대한 답변을 얻을 가능성이 큽니다.

\documentclass{article} 
\usepackage{pgfplots} 
\pgfplotsset{compat=newest} 

\begin{document} 
\begin{tikzpicture} 
    \begin{axis}[ 
    xlabel={$x$ axis label}, 
    ylabel={$y$ axis label}, 
    symbolic x coords={January,February,March,April,May}, 
    ] 
    \addplot [ybar] table [x=Month, y=Dozers, col sep=comma] { 
     Month, Dozers 
     January, 0.85 
     February, 0.7 
     March, 0.6 
     April, 0.9 
     May,  0.4 
    }; 
    \end{axis} 
\end{tikzpicture} 
\end{document} 

enter image description here