From: Johan G. <joh...@gm...> - 2009-11-29 17:24:43
|
Wayne Watson skrev: > Anyway, where, folder, does your program write the files? I'm not > familiar with figure, but apparently using it produces some "canvas" > that plt.hist places it's output on. One can than save fig to a file. > What happens if I don't use figure? I just put a copy of the line > plt.hist([1, 2, 3, 4, 5], range=(0, 20)) after import. When I execute > the program, I don't see a graphic appear. So doesn't matplotlib produce > graphic output aside from use of figure? > My intuition is exactly like that. After importing matplotlib.pyplt as plt, plt.figure creates an object that acts as canvas, and then I plot various things (hist, is one example), and when I am satisfied, I plt.savefig(path) or plt.show() the figure. The figures are saved in the directory where the script is run (its cwd, or current working directory, on linux). I have also used hist without having a figure, but that was because I wanted the histogram data, i.e., the numbers of data points in the different bins. That script used plt.hist to generate such data, and later (after running fig = plt.figure) used plt.plot to plot parts of the data in different ways. By the way, matplotlib.pyplot is one way of using matplotlib. There is also the "object oriented interface", which I have never used. / johan |