Descargar el Código: patreon.com/pythonmaraton
Join Patreon: patreon.com/pythonmaraton
^Downloadable code & more! This walks you through how to plot subplots in matplotlib in python. It teaches how to label the subplots using set_title and set_xlabel and set_ylabel. It also Shows you how to get rid of tick marks using set_xticks and set_yticks. At the end we see the magnificent graph and we explain how to use plt.suptitle("STRING", fontsize = x) to make a title for the entire thing
This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.
✅Subscribe: / @pythonmaraton
📺Channel: / @pythonmaraton
▶️Watch Latest Python Content: • Python String Slice and List Slice
▶️Watch Latest Other Content: • Video
MATPLOTLIB SUBPLOTS
We open ipython and begin by importing py plot from matplotlib and numpy as np so we can use some of it’s functions
In this example we will be making four subplots. So we will name the first one first and define it as a subplot 221. This means it is a 2 by 2 set of subplots and this first one is in position 1
Then we type first.plot to plot the graph. we will make this one sin(x) and let’s make it a red line
We will set some labels on our subplot. Type first dot then the set underscore title. You can do the same for x and y labels. lastly, to make this more clean, we will get rid of the tick marks for our subplot by doing a set_xticks and set_yticks
Now we will do the same things for a second subplot. In the second position of this 2 by 2 so we type 222 when we define it.
Let’s plot this one as cos(x) and we’ll make it a blue solid line.
Similarly we will label the title and axis. and again to make it more clean, for this subplot I’m going to get rid of tick marks by doing a set_xticks and set_yticks
Now as you can imagine we do a similar thing for the third subplot. 2x2 position 3
We will make this one x squared and do a green dashed line
and we will go ahead and label the axis and give it a title
And lastly, we do the same thing for a fourth spot of our 2x2 subpltos
we will call this one fourth to stick with our theme
This will be x cubed graphed with the default color and we’ll make it be dots
finally when we have finished making each plot, we can type plt.show() to show all of them plotted together as subplots
Here it is. You can see the labels for each individual plot. and the titles
Let’s make it bigger so it doesn’t overlap. The reason I got rid of the tick marks was to make it less messy since we have four plots here.
I’ll not if we wanted to make a title for the entire thing type plt.suptitle(“TITLE HERE”) and you can do a keyword font size. that will make a title for the entire things.
There you have it that is how you make subplots using matplotlib in python
#PythonMarathon #LearnPython #PythonTutorial
Nesta página do site você pode assistir ao vídeo on-line Matplotlib Subplot Tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Python Marathon 07 Agosto 2018, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 1,098 vezes e gostou 11 espectadores. Boa visualização!