Graphics, Figures & TablesSmall glitch with a TikZ graphics

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small glitch with a TikZ graphics

Post by Cham »

I need to fix a simple number shown on the main axis of the following graphics :

Code: Select all

Code, edit and compile here:
\documentclass[10pt,oneside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,every tick/.style={black}}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
scale only axis=true,
width=10cm,
height=2cm,
grid=none,
minor tick num=1,
%xtick align=center,
xlabel=$x$,
ytick=\empty,
title={},
xmin=1.48,
xmax=1.54,
ymin=-1,
ymax=3,
axis x line = bottom,
axis y line = none,
legend style={at={(1, 0.45)},anchor=west,font=\footnotesize,draw=black},
]
\addplot+[color=black,mark options={mark=*,mark size=2pt,fill=gray,scale=1},error bars,x dir=both,x explicit]
coordinates {
(1.51, 1.25) +- (0.02, 0)
};
\addlegendentry{$a$};
\addplot+[color=black,mark options={mark=square*,mark size=2pt,fill=gray,scale=1},error bars,x dir=both,x explicit]
coordinates {
(1.504, 0.25) +- (0.003, 0)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Here's a preview of what that code is doing :
diagram.jpg
diagram.jpg (11.11 KiB) Viewed 3540 times
The number indicated in red should read 1.50 instead of 1.5. How can I fix this tiny yet insulting glitch ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Small glitch with a TikZ graphics

Post by mas »

Added this for the axis options

Code: Select all

xticklabel style={
/pgf/number format/precision=2,
/pgf/number format/fixed zerofill}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I got this:
x.png
x.png (4.29 KiB) Viewed 3536 times

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small glitch with a TikZ graphics

Post by Cham »

WOW ! :shock:

It's working, but I would have never found this by myself ! :?

Thanks a lot !
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small glitch with a TikZ graphics

Post by Cham »

Before I mark this problem as solved, is there another way (simpler ?) in doing this ?
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Small glitch with a TikZ graphics

Post by mas »

Cham wrote: It's working, but I would have never found this by myself ! :?
When all else fails, read the manual :D It is on page 23 of the pgfplots manual under the heading "Satisfying Different Tastes".

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Small glitch with a TikZ graphics

Post by Cham »

So there is no other way in doing this ? Should I mark the thread as "solved"?
Post Reply