I want to plot a dataset with pgfplots. In my dataset, 0 < x < 1 and everything interesting happens for values of x close to 1. In particular, the interesting points happen at halving intervals of x: 0.1, 0.15, 0.175, and so on.
So, I would like to do something like the opposite of a logscale plot: use a custom function to specify the progression along the x axis so that my interesting x coordinate are represented at regular intervals. Just like I would do with a logscale if the intervals were doubling.
I know this previous answer, but I was unable to find a suitable function for my case. I guess that I should use the x coord trafo/.code option, but which argument would be suitable for my case?
Any suggestion? Thank you in advance.
Ideally, I would like my x axis to appear like this:
=== 0 === 0.5 === 0.75 === 0.875 === etc.
for a simple dataset like this:
0.10 1
0.20 1
0.30 1
0.40 1
0.50 1
0.60 2
0.70 2
0.75 2
0.80 4
0.85 4
0.875 8
0.900 8
Currently this is my code, that does not obtain the intended result:
\documentclass{standalone}
\usepackage{standalone}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{xfp}
\usepackage{ifthen}
\pgfplotstableread{
0.10 1
0.20 1
0.30 1
0.40 1
0.50 1
0.60 2
0.70 2
0.75 2
0.80 4
0.85 4
0.875 8
0.900 8
}\dataset
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=1,
scaled x ticks=false,
x coord trafo/.code = {\pgfmathparse{\ifthenelse{#1==0}{1-(1/#1)}{0}}\pgfmathresult},
x coord inv trafo/.code = {\pgfmathparse{\ifthenelse{#1==0}{1-(1/#1) }{0}}\pgfmathresult},
scaled y ticks=false,
]
\addplot table [x index = 0 , y index = 1 , col sep=comma]\dataset;
\end{axis}
\end{tikzpicture}
\end{document}
x coord trafotransform the data X coordinate (provide by your file/table) to the screen X coordinate (distance on screen/paper etc.), andx coord inv trafotransform the screen X coordinate to the label X coordinate (the numbers on the labels). Is that clear? – user202729 Dec 20 '21 at 03:16