2011-02-04 18 views
3

LaTeXの使い方で棒グラフを作成しようとしています。 成功していないと、誰も再送プロジェクトのコピーで私を助けることができますか? pstricksで棒グラフを作成するにはどうすればよいですか? TeXを使い始めたばかりなので、できるだけシンプルです。LaTeX棒グラフ

Like mentioned here in the official document

これは私がしようとしているものです:

\psset{unit=0.5in}% 
\begin{pspicture}(0,-0.5)(3,3)% 
\readpsbardata{\data}{example1.csv}% 
\psbarchart[barstyle={red,blue}]{\data}% 
\end{pspicture} 
+0

ok私は何が問題であるかを知ったと思います。私は最初にそれをdviファイルにしなければなりませんか?私は正しい? –

+0

PSTricksでのPDF出力については、[このページ](http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput)を参照してください。 – Philipp

+4

私は答えはありませんが、LaTexの質問についてはhttp://tex.stackexchange.com/を知りたいでしょう。 – mbmcavoy

答えて

8

私は非常にPGF、は、TikZとPGFPlotsの魔法の組み合わせを使用することをお勧めします。これらのツールは、一般にpstricksの代替品として受け入れられています。それらはpdflatexやpstricksに問題を起こす他の多くのツールと互換性があります。

この次の高いセマンティックTeXのソースは

\usepackage{tikz} 
\usepackage{pgfplots} 
\pgfplotsset{compat=1.4} 

\begin{document} 

\begin{tikzpicture} 

\begin{axis}[% 
scale only axis, 
width=5in, 
height=4in, 
xmin=-3, xmax=3, 
ymin=0, ymax=1, 
axis on top] 
\addplot[ 
    ybar, 
    bar width=0.102874in, 
    bar shift=0in, 
    fill=red, 
    draw=black] 
    plot coordinates{ 
    (-2.9,0.00022263) (-2.7,0.000682328) (-2.5,0.00193045) (-2.3,0.00504176) 
    (-2.1,0.0121552) (-1.9,0.0270518) (-1.7,0.0555762) (-1.5,0.105399) 
    (-1.3,0.18452) (-1.1,0.298197) (-0.9,0.444858) (-0.7,0.612626) 
    (-0.5,0.778801) (-0.3,0.913931) (-0.1,0.99005) (0.1,0.99005) 
    (0.3,0.913931) (0.5,0.778801) (0.7,0.612626) (0.9,0.444858) 
    (1.1,0.298197) (1.3,0.18452) (1.5,0.105399) (1.7,0.0555762) 
    (1.9,0.0270518) (2.1,0.0121552) (2.3,0.00504176) (2.5,0.00193045) 
    (2.7,0.000682328) (2.9,0.00022263) 
    }; 

\end{axis} 
\end{tikzpicture} 

\end{document} 

あなたはPST-barパッケージとはpstricksパッケージを使用する必要が

Bar graph example

+0

素敵な答えは、pstricksを置き換えるのが良い選択です私は魔法の組み合わせを見てみましょう;) –

+0

恐ろしい!ちょうど私が必要なもの、ありがとう! – mmr

1

利回り。

\documentclass[12pt]{article} 
\usepackage{pstricks} 
\usepackage{pst-bar} 
\usepackage{pstricks-add} 
\usepackage{filecontents} 

\begin{document} 

\begin{filecontents*}{example1.csv} 
Sun, Mon, Tue, Wed, Thu, Fri, Sat 
1700, 1690, 1600, 1800, 1750, 1210, 1200 
\end{filecontents*} 

\psset{xunit=0.5in,yunit=0.0015in} 
\begin{pspicture}(0,0)(8,2000) 
\psframe[fillstyle=solid,fillcolor=black!10,linestyle=solid](0,0) 
(8,2000) 
\psaxes[yticksize=0 8,ticks=y,labels=y,Dx=1,Dy=500](0,0) 
(0,0)(8,2000) 
\readpsbardata[header=true]{\data}{example1.csv} 
\psbarchart[barstyle=blue]{\data} 
\end{pspicture} 

\end{document}