1

What would be the easiest way to label the x and y axes of a FiPy viewer? I specifically use the fipy.viewers.matplotlibViewer.matplotlib2DGridContourViewer.Matplotlib2DGridContourViewer. I tried giving the the parameter xlabel="some string" but that obviously didn't work because that class doesn't have that parameter. Then I saw that it can take a matplotlib.figure.Axes object as a parameter, but to create one, I would have to have an existing matplotlib.figure.Figure object and so everything is intertwining and I'm lost in documentations with such a seemingly simple goal. Is there some way to add labels simply by giving the Viwer a specific parameter?

Also I looked at the custom Viewer creation examples but I'm not that good in Python, so I would appreciate a detailed solution if I have to take that route.

1 Answers1

1

The MatplotlibViewer classes have an .axes property, which you can use, e.g.,

viewer = fp.MatplotlibViewer(...)
viewer.axes.set_xlabel("some string")

No, this isn't documented anywhere.

The axes= argument is for cases where you have a complicated/custom presentation that you want FiPy to render into, but, as you've discovered, it's a lot of overhead if you're not already doing that.

jeguyer
  • 2,379
  • 1
  • 11
  • 15