2

I'm just trying to get a graph but without any numbers in the axes. Let's say:

from math import pi
from pyx import *

g = graph.graphxy(width=8)
g.plot(graph.data.paramfunction("k", 0, 2*pi, "x, y = sin(2*k), cos(3*k)"))
g.writePDFfile("lissajous")

How do I get rid of axis labels?

2
  • I'd advise reading about it in the pyx manual (available for free at pyx.sourceforge.net/manual.pdf ), at the axis chapter (chapter 10, page 55) Commented Jun 29, 2018 at 16:24
  • @HolyDanna I'm on it. The syntax does is just not that evident. I can get different labelling on the axis but I cannot take out the labels completely. Commented Jun 29, 2018 at 16:41

1 Answer 1

2

To get rid of the text at the axis label, the most easiest solution is to set the labelattrs of the axis painter to None, as discussed at the answer of Python PyX plot: change axes tick text color:

from math import pi
from pyx import *

a = graph.axis.linear(painter=graph.axis.painter.regular(labelattrs=None))
g = graph.graphxy(width=8, x=a, y=a)
g.plot(graph.data.paramfunction("k", 0, 2*pi, "x, y = sin(2*k), cos(3*k)"))
g.writePDFfile("lissajous")

You keep the axis ticks here. If you want to get rid of the ticks as well, you could disable the painter alltogether, and the linkedpainter as well (otherwise you will keep the axis on the other side of the graph, which display the ticks only):

from math import pi
from pyx import *

a = graph.axis.linear(painter=None, linkpainter=None)
g = graph.graphxy(width=8, x=a, y=a)
g.plot(graph.data.paramfunction("k", 0, 2*pi, "x, y = sin(2*k), cos(3*k)"))
g.writePDFfile("lissajous")

This, however, means, that you loose the axis altogether. A simple way out is to add a backgroundattrs=[deco.stroked()] to the graph, even though, technically, it is something very different, and kind of wrong.

Unfortunately, the whole axis partition calculation, is kept running, which also means, that it will keep extending the axis ranges depending on the data ranges. The way out should be to use the most simple axis scheme, with labels and ticks at the beginning and end of the axis ranges, and just disable those. This will probably be handy in all kind of simple cases, and it is kind of wired we don't have that. I will add such a parter in a future PyX release.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.