Closed sphh closed 4 years ago
Well, the top axis, the axis x2
, is created by the graph, if not given. It is a linked axis to x
. It uses a different painter, which has labelattrs
and textattrs
being none.
Now, as the anchored axis x
is created by the graph, you cannot simply pass a linked axis of the same graph directly. But ... PyX itself has the same issue, it needs to set a painter for the linked axis, which needs to be different from the original painter, as it needs to suppress the labels and the title. It is done by the linkpainter attribute of the axis. You just have to adjust that, too.
from pyx import *
mytickattrs=[attr.changelist([style.linewidth.Thin,
style.linewidth.THIn])]
myaxispainter = graph.axis.painter.regular(tickattrs=mytickattrs)
mylinkpainter = graph.axis.painter.linked(tickattrs=mytickattrs)
xaxis = graph.axis.linear(min=-15, max=15,
painter=myaxispainter,
linkpainter=mylinkpainter)
g = graph.graphxy(width=8, x=xaxis)
g.plot(graph.data.function("y(x)=sin(x)/x"))
g.writePDFfile()
It would probably be nice to be able to alter a painter (by call) into a new instance, to make the update step from a painter to a linkedpainter ... we will see in the future, how we progress here.
So many thanks. I got it working now! I would never have figured this out on my own …
How do I change the tick style on all borders?
I use
but this does only change the ticks on the primary x and y axis (bottom and left). Even if I add more
pyx.style.linewidth.THIn
tooyx.attr.changelist([...])
, it does not change the ticks on the right and top axis …