0

Consider below PyX plot

enter image description here

How to arrange graph key so that instead of one verticle list of 4 entries, there are 2 lists (each of 2 entries) side by side?

I mean, instead of key:

x = y^4,

x = y^2,

x = y,

y = x^4,

Having key:

x = y^4, x = y

x = y^2, y = x^4

Here is the code:

from pyx import *
g = graph.graphxy(width=8,
              x=graph.axis.linear(min=0, max=2),
              y=graph.axis.linear(min=0, max=2),
              key=graph.key.key(pos="br", dist=0.1))
g.plot([graph.data.function("x(y)=y**4", title=r"$x = y^4$"),
    graph.data.function("x(y)=y**2", title=r"$x = y^2$"),
    graph.data.function("x(y)=y", title=r"$x = y$"),
    graph.data.function("y(x)=x**4", title=r"$y = x^4$")],
   [graph.style.line([color.gradient.Rainbow])])
g.writePDFfile("change")
Nigel1
  • 95
  • 8
  • 1
    In matplotlib, you can simply use `ncol=2` in the `plt.legend` command. For example, read [this](https://stackoverflow.com/questions/10101141/matplotlib-legend-add-items-across-columns-instead-of-down). – Sheldore Apr 29 '19 at 10:42
  • @Sheldore, thanks - I just tried in PyX but "ncol=2" no works :-( – Nigel1 Apr 29 '19 at 10:49

1 Answers1

1

There is an argument colums for graph.key, which happens to be one, and can be set to two or whatever else you want. http://pyx.sourceforge.net/manual/graph.html#module-graph.key

wobsta
  • 721
  • 4
  • 5