10

I want to have the marks on the x axis at the same position as in the left plotted figure.

\begin{figure}[ht!]
\begin{tikzpicture}
        \begin{axis}[width=7.5cm,
                    ymin=0,
                    xmin=0,
                    xlabel=Zeit t\,/\,min,
                    ytick={0,25,100,160,250},
                    ylabel=Temperatur T\,/\,$^{\circ}$C,]
            \addplot table[x=Zeit,y=Temperatur] {Daten/V27.csv};
        \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[ybar,
            width=7.5cm,
            symbolic x coords={1,2,3,4,5,6,7,8},
            xtick=data,
            ymin=4.5,
            ymax=6,
            xlabel=Probennummer,
            ylabel near ticks,
            %xlabel near ticks,            
            ylabel= Scherfestigkeit F\,/\,MPa,]

            \addplot[fill=blue] coordinates {
                (1,5.30)
                (2,5.84)
                (3,5.64)
                (4,5.56)
                (5,4.69)
                (6,4.95)
            };
\end{axis}
\end{tikzpicture}
\caption{Aufgezeichnete typische stress--strain Kurve und Mittelwerte der Scherergebnisse}
\label{fig:anpress_scher}
\end{figure}

actual result wished result

  • Welcome to TeX.SX! Could explain further what you want to achieve? You are not satisfied with the x ticks position on the bar charts and you would like them to be...? You are mentioning the ticks position of the left graphs but you do not have the same number of x ticks. Could you clarify a bit what you are looking for? – Ludovic C. Oct 27 '13 at 10:34
  • @LudovicC. I guess he wants the ticks to point into the axis instead of out, look at the annotations to the bottom right plot in the screenshot. – Torbjørn T. Oct 27 '13 at 10:51
  • @LudovicC. The first picture (first row) presents obtained result. In the second row there is desired one. – Przemysław Scherwentke Oct 27 '13 at 10:51
  • First Thank you. yes the ticks of the bar chart are on the wrong position. i only want to say that on the left picture the marks are on the top of the axis and on the bar chart the marks are under the x axis. I want that the short lines are on top of the x axis line. Did you know what i mean? – Martin B Oct 27 '13 at 10:56
  • Yes it became clearer when looking at the description of your pictures in the "code" of your question. You should maybe edit your question just to state that what you want is to have the ticks in the chart frame and not outside. – Ludovic C. Oct 27 '13 at 11:01
6

You should use the option xtick align=inside as recommended page 282 of the pgfplots package documentation.

The MWE is now:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{figure}[ht!]
\begin{tikzpicture}
        \begin{axis}[width=7.5cm,
                    ymin=0,
                    xmin=0,
                    xlabel=Zeit t\,/\,min,
                    ytick={0,25,100,160,250},
                    ylabel=Temperatur T\,/\,$^{\circ}$C,]
          %  \addplot table[x=Zeit,y=Temperatur] {Daten/V27.csv};
        \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[ybar,
            width=7.5cm,
            symbolic x coords={1,2,3,4,5,6,7,8},
            xtick align=inside,
            xtick=data,
            ymin=4.5,
            ymax=6,
            xlabel=Probennummer,
            ylabel near ticks,
            %xlabel near ticks,            
            ylabel= Scherfestigkeit F\,/\,MPa,]

            \addplot[fill=blue] coordinates {
                (1,5.30)
                (2,5.84)
                (3,5.64)
                (4,5.56)
                (5,4.69)
                (6,4.95)
            };
\end{axis}
\end{tikzpicture}
\caption{Aufgezeichnete typische stress--strain Kurve und Mittelwerte der Scherergebnisse}
\label{fig:anpress_scher}
\end{figure}

\end{document}

I have commented the first \addplot command since I do not have the file to recreate your plot. And here is the output (obviously the left graph is empty):

Output

NOTE This option can be used in a more generic way for ytick align, ztick align or all at once tick align and the values possible are inside, center and outside. By defaults it should be inside but apparently in your case something changed it to outside for the x ticks.

EDIT It seems that the two graphs are not vertically aligned (the left one is slightly higher than the right one). I thought it was coming from the 6 y tick on the bar charts which is higher than the frame and then the left frame would be aligned with this value but it turned out that even with adding ymax=6.2 and ytick={4.5,5,5.5,6} to the bar chart the frames are still not at the same height.

Output 2

  • 1
    it worked. But there is another trouble. I think you can see that the high of left and right graph are different in the document. Do you know what i mean? the right graph begins a little bit under the left graph. They are on different positions and i do not know why. – Martin B Oct 27 '13 at 11:21
  • 1
    I was also having some problems putting the xticks inside the chart. When using bar plots, the "xtick align = inside" must appear after "ybar". – joão gândara Apr 11 '16 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.