Anpassung von Darstellungen

Python für Fortgeschrittene

Hugo Bowne-Anderson

Data Scientist at DataCamp

Datenvisualisierung

  • Viele Möglichkeiten

    • Verschiedene Diagrammtypen

    • Viele Anpassungsmöglichkeiten

  • Die Wahl hängt ab von

    • Den Daten

    • Der Geschichte, die du erzählen willst

Python für Fortgeschrittene

Einfacher Plot

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100]
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.show()

ch1_3_slides.012.png

Python für Fortgeschrittene

Achsenbeschriftungen

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.show()

ch1_3_slides.012.png

Python für Fortgeschrittene

Achsenbeschriftungen

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.show()

ch1_3_slides.014.png

Python für Fortgeschrittene

Titel

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.show()

ch1_3_slides.015.png

Python für Fortgeschrittene

Titel

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.show()

ch1_3_slides.017.png

Python für Fortgeschrittene

Teilstriche

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10])
plt.show()

ch1_3_slides.019.png

Python für Fortgeschrittene

Teilstriche

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10])
plt.show()

ch1_3_slides.020.png

Python für Fortgeschrittene

Teilstriche (2)

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
['0', '2B', '4B', '6B', '8B', '10B'])
plt.show()

ch1_3_slides.021.png

Python für Fortgeschrittene

Teilstriche (2)

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

plt.plot(year, pop)

plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
['0', '2B', '4B', '6B', '8B', '10B'])
plt.show()

ch1_3_slides.027.png

Python für Fortgeschrittene

Hinzufügen historischer Daten

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

# Add more data year = [1800, 1850, 1900] + year pop = [1.0, 1.262, 1.650] + pop
plt.plot(year, pop)
plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
['0', '2B', '4B', '6B', '8B', '10B'])
plt.show()

ch1_3_slides.028.png

Python für Fortgeschrittene

Hinzufügen historischer Daten

population.py

import matplotlib.pyplot as plt
year = [1950, 1951, 1952, ..., 2100] 
pop = [2.538, 2.57, 2.62, ..., 10.85]

# Add more data year = [1800, 1850, 1900] + year pop = [1.0, 1.262, 1.650] + pop
plt.plot(year, pop)
plt.xlabel('Year') plt.ylabel('Population')
plt.title('World Population Projections')
plt.yticks([0, 2, 4, 6, 8, 10],
['0', '2B', '4B', '6B', '8B', '10B'])
plt.show()

ch1_3_slides.030.png

Python für Fortgeschrittene

Vorher vs. nachher

ch1_3_slides.031.png

Python für Fortgeschrittene

Lass uns üben!

Python für Fortgeschrittene

Preparing Video For Download...