Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is my first try with pgfplots and I have two problems that I need help with. The code is the following:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{verbatim}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
width=10cm,
height=8cm,
ybar,
ymin=0,
ymax=12000,
ymajorgrids=true,
legend style={at={(0.5,-0.2)},
anchor=north,legend columns=-1},
ylabel={Query Response Time (in ms)},
xlabel={Queries},
symbolic x coords={SA1,SA2,SA3,GA1,GA2,GA3},
%xtick=\empty,
ytick={0,2000,4000,6000,8000,10000},
yticklabels={0,2000,4000,6000,8000,10000},
]
\addplot coordinates {(SA1,192) (SA2,597) (SA3,21) (GA1,750) (GA2,1650) (GA3,489) };
\addplot coordinates {(SA1,300) (SA2,1000) (SA3,226) (GA1,2875) (GA2,8719) (GA3,2235) };
\addplot coordinates {(SA1,375) (SA2,1297) (SA3,360) (GA1,4500) (GA2,10871) (GA3,4580) };
\legend{AQ,CAA,Virtuoso}
\end{axis}
\end{tikzpicture}

\end{document}

This generates the following plot:

Question 1: How do I get rid of the $*10^4$ at the top of the y-axis?

Question 2: How do I get rid of the x-axis ticks? I tried to put in xtick=\empty, but that gave an error.

enter image description here

share|improve this question
add comment

1 Answer

Question 1: Use the scaled y ticks key and let pgfplots do the labels (ie do not specify the key ytickslabel).

Question 2: Use the major x tick style setting it to transparent so that they won't be visible.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
  \begin{axis}[
    width = 10cm,
    height = 8cm,
    major x tick style = transparent,
    ybar,
    ymin = 0,
    ymax = 12000,
    ymajorgrids = true,
    legend style = {%
      at = {(0.5,-0.2)},
      anchor = north,
      legend columns = -1},
    ylabel = {Query Response Time (in ms)},
    xlabel = {Queries},
    symbolic x coords = {SA1,SA2,SA3,GA1,GA2,GA3},
    ytick = {0,2000,4000,6000,8000,10000},
    scaled y ticks = false,
    ]
    \addplot coordinates {(SA1,192) (SA2,597) (SA3,21) (GA1,750) (GA2,1650) (GA3,489) };
    \addplot coordinates {(SA1,300) (SA2,1000) (SA3,226) (GA1,2875) (GA2,8719) (GA3,2235) };
    \addplot coordinates {(SA1,375) (SA2,1297) (SA3,360) (GA1,4500) (GA2,10871) (GA3,4580) };
    \legend{AQ,CAA,Virtuoso}
  \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thank you. THe first problem is solved. For the second, when I use your solution, I also lose the x-axis labels, which are important. I was only trying to remove the tick marks. Is that possible? –  ozsu Feb 23 '12 at 15:41
    
Should have mentioned that the reason xtick = \empty did not work for me originally seems to be because I had an older version of pgfplots. –  ozsu Feb 23 '12 at 15:45
    
@user8801 See my edited answer. –  cjorssen Feb 23 '12 at 16:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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