2

I have another question for you. I am currently using the function contour

import matplotlib.pyplot as plt
cs = plt.contour(Z,X_,axial, levels = calc_levels,colors='k')

I would like to create the contour object cs without having to plot the contours to a figure, I need to find the contour of 1000's of objects and can do without 1000's of figures. (I'm using the contour object to calculate areas at different heights and only want to return the area value, question here)

I was thinking the best way of achieving this is to edit the function's code, but I don't know how to access it.

From other questions I have read about about accessing source code I have tried

import inspect
inspect.getsourcelines(plt.contour)

but I don't think what is returned is the code. At least it's not what I was expecting and doesn't look like code to my noob eyes!

Would you be able to help me with this please? Thanks

Community
  • 1
  • 1
jlt199
  • 2,349
  • 6
  • 23
  • 43
  • Possible duplicate of [calling contour without plotting it, python, pylab inline](http://stackoverflow.com/questions/30376897/calling-contour-without-plotting-it-python-pylab-inline) – Suever Mar 16 '17 at 15:33
  • You can close the figures: `plt.close(figure)` after retrieving what you want from them. You can also try `plt.ioff()` after importing matplotlib to avoid opening the graphics without an explicit `plt.show()`. – berna1111 Mar 16 '17 at 16:58

0 Answers0