Graphics, Figures & TablesThousand Separator for Value Nodes in Plots

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Didou139
Posts: 2
Joined: Thu Feb 07, 2013 4:04 pm

Thousand Separator for Value Nodes in Plots

Post by Didou139 »

Hi all,

with the pgfplots package, I have a problem with thousands separator of the node. I would like to have no thousands separator. For the x tick labels, I found the solution (xticklabel style={/pgf/number format/1000 sep=}) but not for the node value (see code below).

Code: Select all

\begin{tikzpicture}[scale=1.4]
 \begin{axis}[,xbar, bar width=36pt,
 enlarge y limits, xmajorgrids,xlabel={Value X}, xticklabel style={/pgf/number format/1000 sep=},
nodes near coords, nodes near coords align={anchor=west},
 xmin =0, ymin=0.5, ymax=3.5, ytick= {1,2,3}
, yticklabels={value1,value2 ,Value3}]
\addplot coordinates {(1471.2,1) (200.6,2) (157.3,3)}; 
\end{axis}
\end{tikzpicture}

Many thanks in advance
Didou139
Last edited by Stefan Kottwitz on Thu Feb 07, 2013 4:50 pm, edited 1 time in total.

Recommended reading 2024:

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

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

Thousand Separator for Value Nodes in Plots

Post by localghost »

There is a style called every node near coord that determines the appearance of those nodes. Give it the same parameters and you get what you are after (see below code).

Code: Select all

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}

\begin{document}
  \begin{tikzpicture}
    \begin{axis}[
      xmin=0,
      xmax=2000,
      xbar,
      xmajorgrids,
      xlabel={Value X},
      xticklabel style={/pgf/number format/1000 sep=},
      ymin=0.5,
      ymax=3.5,
      ytick= {1,2,3},
      yticklabels={Value1,Value2,Value3},
      bar width=36pt,
      enlarge y limits,
      nodes near coords,
      nodes near coords align={anchor=west},
      every node near coord/.style={/pgf/number format/1000 sep=}
    ]
      \addplot coordinates {(1471.2,1) (200.6,2) (157.3,3)};
    \end{axis}
  \end{tikzpicture}
\end{document}
For details please refer to the package manual.


Best regards and welcome to the board
Thorsten
Attachments
tmp.png
tmp.png (4.91 KiB) Viewed 8348 times
Didou139
Posts: 2
Joined: Thu Feb 07, 2013 4:04 pm

Re: Thousand Separator for Value Nodes in Plots

Post by Didou139 »

That's very nice,
Many thanks !
Didou139
Post Reply