0

I have plot in PyX in python

  g = graph.graphxy(width=8,
          x=graph.axis.log(min=1e-1, max=1e4, title=r"$x$-axis"),
          y=graph.axis.lin(max=5, title=r"$y$-axis"))
  g.plot(graph.data.function("y(x)=tan(log(1/x))**2"))
  g.writeEPSfile("axis")

How to change color background of plot from transparent to white?

Nigel1
  • 95
  • 8

2 Answers2

1

You can change this using the backgroundattrs attribute.

class graph.graph.graphxy(xpos=0, ypos=0, width=None, height=None, 
                          ratio=goldenmean, key=None, backgroundattrs=None, 
                          axesdist=0.8*unit.v_cm, xaxisat=None, yaxisat=None, **axes)

backgroundattrs is a list of attributes for drawing the background of the graph. Allowed are decorators, strokestyles, and fillstyles. None disables background drawing.

iacob
  • 20,084
  • 6
  • 92
  • 119
0

The background of a graph is drawn, when its backgroundattrs is set. In order to fill the background, you need the filled decorator, and pass the color either as an attr to the filled decorator or as a backgroundattr (to be applied to all decorators). Hence

g = graph.graphxy(width=8, backgroundattrs=[deco.filled([color.gray.white])],
                  x=graph.axis.log(min=1e-1, max=1e4, title=r"$x$-axis"),
                  y=graph.axis.lin(max=5, title=r"$y$-axis"))
g.plot(graph.data.function("y(x)=tan(log(1/x))**2"))
g.writeEPSfile("axis")
wobsta
  • 721
  • 4
  • 5