Ich bin absoluter Python Neuling, möchte mich aber mit dem Thema beschäftigen da es mich Interessiert und Python auch in der Berufsschule benutzt wird. Ich bin gerade dabei was zu schreiben, was 2 Preise vergleicht, in dem Fall von Angeboten. Diese werden auch schon grafisch in form eines einfaches Diagramm ausgegeben. Jetzt wollte ich fragen, wie ich die Ausgabe 2-farbig machen kann (linker Balken blau, rechter rot etc.) Perfekt wäre es, wenn Python das günstigere Angebot in z.B. grün und das teuere in rot ausgibt.
Ich danke euch schon mal im vor raus und hoffe viel lernen zu können.
Arbeit bisher:
Code: Alles auswählen
import matplotlib.pyplot as plt
def Endpreis(Grundpreis, Stueckpreis, Stueckzahl):
return Grundpreis + Stueckpreis * Stueckzahl
#Eingabe
Grundpreis1 = float(input("Grundpreis:"))
Stueckpreis1 = float(input("Stückpreis:"))
Stueckzahl1 = int(input("Stückzahl:"))
Grundpreis2 = float(input("Grundpreis:"))
Stueckpreis2 = float(input("Stückpreis:"))
Stueckzahl2 = int(input("Stückzahl:"))
#Verarbeitung
Pr1 = Endpreis(Grundpreis1, Stueckpreis1, Stueckzahl1)
Pr2 = Endpreis(Grundpreis2, Stueckpreis2, Stueckzahl2)
#Ausgabe
y = [Pr1, Pr2]
N = len(y)
x = range(N)
width = 1/1.05
plt.bar(x,y, width, color="black")