0

So I have some issues with the rounding of fractions, and I know that calculating fractions is notoriously difficult for a computer, so I am not too surprised this is not as easy as I want it to be.

I want my y-coordinate ticks to be fractions, and I want them to be the ones I gave as arguments (i.e. 1/36, 2/36, ...):

Minimal working example:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{fp}

\begin{document}

\begin{tikzpicture} \begin{axis}[axis lines =center, ytick={(1/36),(2/36),...,(6/36)}, yticklabel style={/pgf/number format/frac}, ymin=0, ymax = 0.2, xmin=0, xmax = 1.4] \addplot [fill=cyan, fill opacity=0.5] {1/36 * x}; \end{axis} \end{tikzpicture}

\end{document}

However, the result are...some less compelling fractions:

enter image description here

PS: I don't know what exactly the fp package does, but Overleaf recommended using it (it didn't resolve my issue though).

lurgold
  • 13
  • Did you see https://tex.stackexchange.com/q/410354/47927 ? – Jasper Habicht Jul 14 '23 at 14:49
  • That already helps quite a bit. I do want the non-simplified fraction version, and I can live with spelling them all out, I guess I'll never have that many of them. If there's a not too complicated way to automate that with something like the a,...,b-system, I'm still interested, but this is definitely good enough for now. I wonder why I didn't find the thread while searching.

    Thanks for the link!

    – lurgold Jul 14 '23 at 15:24

0 Answers0