{"action":"created","issue":{"url":"https://api.github.com/repos/sncosmo/sncosmo/issues/75","labels_url":"https://api.github.com/repos/sncosmo/sncosmo/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/sncosmo/sncosmo/issues/75/comments","events_url":"https://api.github.com/repos/sncosmo/sncosmo/issues/75/events","html_url":"https://github.com/sncosmo/sncosmo/issues/75","id":57344716,"number":75,"title":"plot_lc doesn't close figures, resulting in MPL RuntimeWarning","user":{"login":"drhay53","id":5826711,"avatar_url":"https://avatars.githubusercontent.com/u/5826711?v=3","gravatar_id":"","url":"https://api.github.com/users/drhay53","html_url":"https://github.com/drhay53","followers_url":"https://api.github.com/users/drhay53/followers","following_url":"https://api.github.com/users/drhay53/following{/other_user}","gists_url":"https://api.github.com/users/drhay53/gists{/gist_id}","starred_url":"https://api.github.com/users/drhay53/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drhay53/subscriptions","organizations_url":"https://api.github.com/users/drhay53/orgs","repos_url":"https://api.github.com/users/drhay53/repos","events_url":"https://api.github.com/users/drhay53/events{/privacy}","received_events_url":"https://api.github.com/users/drhay53/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-11T17:02:58Z","updated_at":"2015-02-11T17:31:37Z","closed_at":null,"body":"When looping over many light curves and saving figures with plot_lc, after ~20 MPL spits out a RuntimeWarning since the figures are never closed. \r\n\r\n    RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_num_figures`). max_open_warning, RuntimeWarning)"},"comment":{"url":"https://api.github.com/repos/sncosmo/sncosmo/issues/comments/73924645","html_url":"https://github.com/sncosmo/sncosmo/issues/75#issuecomment-73924645","issue_url":"https://api.github.com/repos/sncosmo/sncosmo/issues/75","id":73924645,"user":{"login":"kbarbary","id":970135,"avatar_url":"https://avatars.githubusercontent.com/u/970135?v=3","gravatar_id":"","url":"https://api.github.com/users/kbarbary","html_url":"https://github.com/kbarbary","followers_url":"https://api.github.com/users/kbarbary/followers","following_url":"https://api.github.com/users/kbarbary/following{/other_user}","gists_url":"https://api.github.com/users/kbarbary/gists{/gist_id}","starred_url":"https://api.github.com/users/kbarbary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbarbary/subscriptions","organizations_url":"https://api.github.com/users/kbarbary/orgs","repos_url":"https://api.github.com/users/kbarbary/repos","events_url":"https://api.github.com/users/kbarbary/events{/privacy}","received_events_url":"https://api.github.com/users/kbarbary/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T17:31:37Z","updated_at":"2015-02-11T17:31:37Z","body":"I don't think there's much more we can do here, except perhaps better documentation. Here's exactly what happens:\r\n\r\n* If you specify the `fname` keyword argument, the figure is saved to that file name and it *is* closed. Nothing is returned (or more precisely, `None` is returned).\r\n* If you don't specify `fname`, the figure itself is returned. Since we're returning the figure for the user to do something with, we can't close it within `plot_lc`. However, the latest docs do say:\r\n```\r\nfig : matplotlib Figure\r\n    Only returned if fname is None. Display to screen with plt.show() or save\r\n    with fig.savefig(filename). When creating many figures, be sure to close\r\n    with plt.close(fig).\r\n```\r\nYou might not have seen that if you were looking at the default docs page (v0.4).\r\n\r\nAny ideas for what could be better in terms of behavior or docs?"}}