maandag 30 september 2019

matplotlib https://matplotlib.org/3.1.1/tutorials/introductory/pyplot.html

https://matplotlib.org/3.1.1/tutorials/introductory/pyplot.html

Why f, ax = plt.subplots()

 
f, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Simple plot')


plt.subplots() is a function that returns a tuple containing a figure and axes object(s). Thus when using fig, ax = plt.subplots() you unpack this tuple into the variables fig and ax.
 Having fig is useful if you want to change figure-level attributes or save the figure as an image file later (e.g. with fig.savefig('yourfilename.png')). You certainly don't have to use the returned figure object but many people do use it later so it's common to see.
Also, all axes objects (the objects that have plotting methods), have a parent figure object anyway, thus:

fig, ax = plt.subplots()

is more concise than this:
 
fig = plt.figure()
ax = fig.add_subplot(111)
 
 
 
plt.plot([1, 2, 3, 4], [1, 4, 9, 16]) 


Plot Geodataframe kleur


Geen opmerkingen:

Een reactie posten

Datums bepalen adhv begin en einddatum in Dataframe

Voorbeeld op losse velden  ####################################################################### # import necessary packages from datetime...