Graphics, Figures & Tables ⇒ vertical chart
Re: vertical chart
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
vertical chart
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
vertical chart
Code: Select all
\documentclass[spanish]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{ifplatform}
\usepackage{pst-pdf}
\usepackage{xkeyval}
\usepackage{auto-pst-pdf}
\deactivatetilden
\usepackage{pst-bar,pst-all,pstricks-add}
\begin{document}
\psset{xunit=1cm,yunit=1cm}%
\renewcommand*\psbarlabelsep{50pt}
\begin{pspicture}(0,0)(10,9)%
\psgrid[yunit=1cm,gridlabels=0,subgriddiv=0,griddots=30](0,0)(10,8.1)%
\psaxes[labels=all,ticks=x](0,0)(10,9)%
\readpsbardata{\graphs}{graphs.dat}%
\psbarchart[labelFontSize=2pt,shadow=true,barstyle=blue,barcolsep=0.3,orientation=horizontal]{\graphs}%
\rput(-1.4,7.5){Scatter Graphs}
\rput(-1.7,6.5){Frequency Polygon}
\rput(-1.25,5.5){Line Graphs}
\rput(-1.75,4.5){Comp. Pie Graphs}
\rput(-1.2,3.5){Pictograms}
\rput(-1.2,2.5){Histograms}
\rput(-1.2,1.5){Pie Graphs}
\rput(-1.2,0.5){Bar Charts}
\end{pspicture}
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
vertical chart
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: vertical chart
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
vertical chart
I wonder about this file called »graphs-autopp.pdf«. Actually there should be a file with the name »graphs-pics.pdf«. You can try a very minimal example.krislodz wrote:It is still not producing the valid pdf, the output goes to file graphs-autopp.pdf and when I try to build the original document with the graph, it is not there.
Code: Select all
\listfiles
\documentclass{minimal}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{xunit=1cm,yunit=1cm}%
\renewcommand*\psbarlabelsep{50pt}
\begin{pspicture}(0,0)(10,9)%
\psgrid[yunit=1cm,gridlabels=0,subgriddiv=0,griddots=30](0,0)(10,8.1)%
\psaxes[labels=all,ticks=x](0,0)(10,9)%
\readpsbardata{\graphs}{graphs.dat}%
\psbarchart[labelFontSize=2pt,shadow=true,barstyle=blue,barcolsep=0.3,orientation=horizontal]{\graphs}%
\rput(-1.4,7.5){Scatter Graphs}
\rput(-1.7,6.5){Frequency Polygon}
\rput(-1.25,5.5){Line Graphs}
\rput(-1.75,4.5){Comp. Pie Graphs}
\rput(-1.2,3.5){Pictograms}
\rput(-1.2,2.5){Histograms}
\rput(-1.2,1.5){Pie Graphs}
\rput(-1.2,0.5){Bar Charts}
\end{pspicture}
\end{document}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: vertical chart
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: vertical chart
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 34
- Joined: Sun Oct 16, 2011 5:56 pm
vertical chart
a different approach might be to use pgfplots. It is based on TikZ/PGF rather than pstricks.
Here is what I got so far:
Code: Select all
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=0,
xtick={0,...,10},
xmajorgrids,
ytick=data,
yticklabels={%
Scatter Graphs,%
Frequency Polygon,%
Line Graphs,%
Comp. Pie Graphs,%
Pictograms,%
Histograms,%
Pie Graphs,%
Bar Charts,%
},
]
\addplot table[
x=Value,
% \coordindex is 0...7,
% but I want it upwards such that it fits
% the yticklabels list (which is read from top to bottom).
y expr=-\coordindex,
]
{
Value
5
1
9
4
8
3
2
5
};
\end{axis}
\end{tikzpicture}
\end{document}
Inside of the axis environment, it expects zero, one, or more
\addplot
statements. In our case, we load data from an inline table and plot the "Value" column against -\coordindex
. The - sign is confusing, I admit it: it is because the list of tick labels starts at the top ... and indices start "at the bottom" (at y=0). You will understand my idea if you omit the yticklabels key.Alternatively, you got write the labels into the very same table and load the tick labels from the table:
Code: Select all
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xbar,
xmin=0,
xtick={0,...,10},
xmajorgrids,
ytick=data,
table/col sep=semicolon,
yticklabels from table={data.dat}{Label},
]
\addplot table[
x=Value,
y expr=-\coordindex,
]
{data.dat};
\end{axis}
\end{tikzpicture}
\end{document}
Code: Select all
Value;Label
5;Scatter Graphs
1;Frequency Polygon
9;Line Graphs
4;Comp. Pie Graphs
8;Pictograms
3;Histograms
2;Pie Graphs
5;Bar Charts