PSTricks: Wrong axis labels
You've got conflicting directives going on for the x-axis. Try something like:
\documentclass{article}
\usepackage{pstricks-add}
\def\sandsynlighed#1#2{%
\psframe[
linecolor=red,
fillstyle=solid,
fillcolor=blue!50
](#1,0)(!#1 \bredde add #2 4 div)
}
\psset{unit=0.75}
\begin{document}
\def\bredde{1.5 }
\begin{pspicture}(-0.9,-0.5)(14.3,11.3)
\psaxes[
xlabelOffset=-0.75,
%%Ox=-1,
%%dx=1.5,
xLabels={0,1,2,3,4,5,6_{+0},6_{+1},7},
Dy=2,
dy=0.5
]{->}(14,10)[$X$,0][$100 \cdot P(X)$,90]
% Sandsynlighederne.
\sandsynlighed{0}{18.70}
\end{pspicture}
\end{document}
UPDATE
Given your comment, here's a fairly different approach. Here I delved into the pst-plot
package to look at how labels are placed and copied some of the code. The key here is the \multido
macro. Also, since the label positions are enumerated with \nA
, but we're stepping by 2
, I added another counter \nB
to extract the correct label from \psk@xLabels
. All this is wrapped up in the macro \myxlabels
To get the desired spacing, I set the xunit
to a new value. Perhaps you may not want to do this globally. If so, then just reassign xunit
within a group enclosing the pspicture
.
Also, you don't need to add the extra space to \bredde
as you did. You can use \space
in the call to the post-script commands.
Here's a new MWE:
\documentclass{article}
\usepackage{pstricks-add}
\def\sandsynlighed#1#2{%
\psframe[
linecolor=red,
fillstyle=solid,
fillcolor=blue!50
](#1,0)(!#1 \bredde\space add #2 4 div)
}
\makeatletter
\def\myxlabels#1{\def\psk@xLabels{#1}%%'
\multido{\nA=1+2,\nB=0+1}{10}{\uput{\psxlabelsep}[-90]{\pst@xLabelsRot}(\nA,0)%%'
{\strut\pshlabel{\psPutXLabel{\nB}}}}%%'
}
\makeatother
\psset{unit=0.75,xunit=0.75}
\begin{document}
\def\bredde{2}
\begin{pspicture}[](-0.9,-0.5)(14.3,11.3)
\psaxes[
dx=2,
xLabels={,},
Dy=2,
dy=0.5
]{->}(20,10)[$X$,0][$100 \cdot P(X)$,90]
%% Sandsynlighederne.
\myxlabels{0,1,2,3,4,5,6_{+0},6_{+1},7}
\sandsynlighed{0}{18.70}
\end{pspicture}
\end{document}
the offset was not working for special label setting. Try pst-plot.tex
from http://texnik.dante.de/tex/generic/pst-plot/ Then use something like:
\documentclass{article}
\usepackage{pstricks-add}
\def\sandsynlighed#1#2{%
\psframe[linecolor=red,fillstyle=solid,
fillcolor=blue!50](#1,0)(!#1 \bredde add #2 4 div)}
\psset{unit=0.75}
\begin{document}
\def\bredde{1.5 }
\begin{pspicture}(-0.9,-0.5)(14.3,11.3)
% Akserne.
\psaxes[
xunit=1.5,
xLabels={,0,1,2,3,4,5,6_{+0},6_{+1},7},
xlabelOffset=-0.75,
Dy=4,dy=1,
]{->}(9,10.75)[$X$,0][$100 \cdot P(X)$,90]
% Sandsynlighederne.
\sandsynlighed{0}{18.70}
\end{pspicture}
\end{document}