Matplotlib Tutorial 5 - stack plots

preview_player
Показать описание
In this Matplotlib data visualization tutorial, we cover how to create stack plots. The idea of stack plots is to show "parts to the whole" over time. A stack plot is basically like a pie-chart, only over time.

Let's consider a situation where we have 24 hours in a day, and we'd like to see how we're spending out time. We'll divide our activities into: Sleeping, eating, working, and playing.

Рекомендации по теме
Комментарии
Автор

I found this guy searching for neural networks and after the python basics and face recognition, started the matplotlib series. This guy has something my teachers didn't.

PsychOpathy
Автор

There is a "labels" argument to the stackplot function, at least in recent versions: plt.stackplot(x, y1, y2, labels=['label1', 'label2'])
Also, passing in a list of colors like shown in this tutorial generates a deprecation warning since Matplotlib 1.5:
MatplotlibDeprecationWarning: The set_color_cycle attribute was deprecated in version 1.5. Use set_prop_cycle instead.

Majskolvenz
Автор

Your channel is wonderful... i dont even know where to begin because everything is so useful. Sticking w/ these matplots for now. Kind of new to python... long time BI developer.

jasonclement
Автор

Great video! Just thought I would let you know currently matplotlib has been updated so you can add labels to stacked plots, I used the command:
"labels=["Sleeping", "Eating", "Working", "Playing"]"
inside
"plt.stackplot(days, sleeping, eating, working, playing, colors=["m", "c", "r", "k"], labels=["Sleeping", "Eating", "Working", "Playing"])"
which worked for me

jacob.
Автор

Wow man you are killing it when it comes to explaining. Way better than the site tutorial for like 90% of stuff thanks!

jamu
Автор

Correct me if I am wrong but cant we just use the label like this:
plt.stackplot(days, sleeping, working, eating, playing, colors = ['m', 'c', 'r', 'k'], labels = ['sleeping', 'working', 'eating', 'playing'])
it works fine in my program.

vishu
Автор

For newer versions of MPL, your line for plt.stackplot should look something like:
plt.stackplot(days, sleeping, eating, working, playing, labels=["days", "sleeping", "eating", "working", "playing"]) - worked for me!

SamOween
Автор

I am beginning to learn Python. Your ttutorials are very illuminating. Thanks.

arceniocornejo
Автор

Just started learning Matplotlib. These videos are really useful. Thanks!

michaeldufton
Автор

hi, It's pretty messed up that no one is polite enough to tell you it's pronounced "muh-jen-ta", anyways you're the man and thanks for uploading this content as well as the copious amounts of other videos and comments!

figjam-jhib
Автор

Thannks sentdex, for this unique series.

Ninja-iqxt
Автор

I like how you effortlessly added all the hours up to 24 meanwhile I'm over here with 14 hour days on my chart..

MbkeliteVlog
Автор

In my case it didn't work in any way except when I included the list in the legend -> plt.legend(['sleeping', 'eating', 'working', 'playing']).

inigoalonso
Автор

"I get all mine from the sun" lol

veronaswindall
Автор

I loved this workaround when you can't label the fills from the stackplot.

kareemjeiroudi
Автор

When you get older, the time you spend sleeping and playing decreases and the time you spend working and eating increases.

mitchellfolbe
Автор

I am using this for data visualization. Which is the best one for it?

KartikeyRiyal
Автор

Can you create a "hover-over" annotation for each set of y values along the x-axis? For example, for each point along the x-axis, instead of--or in addition to--the line colors, can you annotate the values for 'sleeping', 'eating', 'working' and 'playing', such that when your mouse pointer hovers over an x-value, the y-values for each category displays?

Example: Mouse pointer hovers over Day 1, and the legend shows the values for each category on Day 1. Hover over Day 4, any the values for each category for Day 4 are displayed.

Also: Is there a way to create a movable vertical line that corresponds to each x-axis value to show the user his/ her position relative to the x-axis? (there may be a technical name for this type of line, but I don't know it).

Hope that this makes sense.

michaelbachman
Автор

Pronounce it like "majenta".

gmc
Автор

1:28 "I don't know what a typical human sleeps", neither me pal

andersonfs