1

I've been trying to do it for several hours and I have a mistake every time. I want to create 3 bar plots in one graph. The y-axis is to be between 0 and 1000. The end result should be this

imgur

Thats my code:

import matplotlib.pyplot as plt
import numpy as np
import csv

df = pd.read_csv('razemKM.csv')
dfn = pd.read_csv('razemNPM.csv')
print(df)
y=[0,1000]
a=(df["srednia"]-df["odchStand"])
a1=df["srednia"]
a2=(df["srednia"]+df["odchStand"])

plt.bar(y,a,width=0.1,color='r')
plt.bar(y,a1,width=0.1,color='g')
plt.bar(y,a2,width=0.1,color='y')


plt.show()

1 Answer 1

1

You can use pandas plot function:

df['Sum'] = df["srednia"]+df["odchStand"]
df['Dif'] = df["srednia"]-df["odchStand"]

df.plot.bar(y=['Diff','srednia', 'Sum'],width=0.1)
plt.show()
Sign up to request clarification or add additional context in comments.

1 Comment

thanks, i also want to change the signatures from the X axis to the names from my csv. It's in the df

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.