1

i'm beginner developer. i don't know what it means.

fig: plt.Figure = plt.figure()
ax: plt.Axes = fig.add_axes((0, 0, 1, 1))

i want to know what means : in this code
i guessed that plt.figure()'s return will be arguments about plt.Figure
and return value about plt.Figure will pass to fig in this sentence

but i'm not sure it is right flow.
i tried search in google but string ':' was dismissed..

thx for reading it. have a good day

Bro K
  • 43
  • 7
  • 2
    A note on searching: if you google for [Python colon after variable](https://www.google.com/search?q=python+colon+after+variable), the very first hit explains it. – Konrad Rudolph Oct 15 '20 at 08:51
  • 1
    Seems like annotations, here's a reference: https://realpython.com/lessons/annotations/ – Andre Oct 15 '20 at 08:53

1 Answers1

1

: plt.Figure is a type annotation. For example:

x: int = 5
y: str = "hello"

So in your example, fig is a variable with type plt.Figure, and is assigned the returned value of plt.figure().

TerryA
  • 58,805
  • 11
  • 114
  • 143